Saturday, 3 September 2016

Make JFrame unmovable, unclosable, unminimizable, unresizable & unmaximizable in Java Swing

Suppose, you have to develop a application which requires desktop locking- means user can not use the system if you don't allow to use it. For such kind of application we require that (I assume that it is a swing application) the JFrame should not be closed, maximized, minimized or movable.

To do so, we require remove title bar along with close, maximize and minimize buttons (windows buttons), so that JFrame could not be closed, moved, maximized or minimized

setUndecorated(true);    //remove title bar

setResizable(false);      //make frame static

setType(javax.swing.JFrame.Type.UTILITY);     //Jframe will not show in task bar

setAlwaysOnTop(true);       //set always on top if we don't close it using any action


Dynamically create rows, checkboxes, buttons in JSP/JAVA

Generally we create rows, check boxes, buttons, hyperlink statically. But when we want it to create dynamically or when we have to associate it with row fetched from database and we don't know the exact result has to come.

If we want to create fixed number of elements dynamically, obviously we use loop like that

<table>
<%
int i=0;
while(i<=10)
{
%>
              <tr><td>your data</td></tr>   //it prints 10 table row
              <input  type="search"  />        // it prints 10 textfield
              <input type="submit" value="Search" />   // it prints 10 buttons
              ..... and so on 
<%
i++;
}
%>
</table>


If we get data from database and want these elements to associate with this then

just change the loop

while(rs.next())
{
// put your elements according to you//
}



Multi select Checkbox

We stuck at some situation where checkboxes are generated dynamically- generally when we fetch data from database- and we have to select  some row are all rows and do some operation on that.

If we don't have multi select checkbox option we will have to select one by one and if there are too many data it will be time-consuming and irritating.

To do this we require Jquery with javascript.

1. Add jquery.min.js to file-

<script src="js/jquery.min.js"></script>

2. Use javascript to file-

$(document).ready(function(){
    $('#select_all').on('click',function(){
        if(this.checked){
            $('.checkbox').each(function(){
                this.checked = true;
            });
        }else{
             $('.checkbox').each(function(){
                this.checked = false;
            });
        }
    });
    
    $('.checkbox').on('click',function(){
        if($('.checkbox:checked').length == $('.checkbox').length){
            $('#select_all').prop('checked',true);
        }else{
            $('#select_all').prop('checked',false);
        }
    });
});

3. Then create master checkbox-

<input type='checkbox' id='select_all' />

4. Now another checkboxes will be-


<input name='rid[]' type='checkbox' class='checkbox' value='<?php echo $row[0];?>' />

All done .

It looks like-


 




Monday, 8 August 2016

Popularity of programming languages

Enjoy Online Shopping

Is there any way to measure the popularity of any programming language ? And how to know that which programming language is used widely worldwide?

It is very difficult to give accurate rank to a programming language. Some programming languages are very popular, in fact appropriate in a specific application development like C is good for system programming. Programming language popularity depends on many factor like its complexity, line of code,  CPU time and some others.

There are several methods are applied to calculate the popularity of a programming language. Some are

  •  number of skilled engineers world-wide, 
  • courses and third party vendors. 
  • Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu trends 
  • languages used in public & private repositories
  • counting the number of job advertisements that mention the language
  • the number of books sold that teach or describe the language
Most useful and widely used method is search trends on popular search engine like Google and programming traction on GitHub (Uses) and discussion on stackoverflow.

Apart from these methods, there are many other methods are use to calculate the popularity of a language.

Note that, these methods do not tell the best programming language that means if any programming language has high ranking in published indices, does not means that it  is a best programming language.

There are several indices are published yearly/monthly  showing the popularity of programming languages, and they apply different mechanism to generate this. Some are given below:- 

TIOBE Index for programming languages

The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

The index can be used to check whether your programming skills are still up to date or to make a strategic decision about what programming language should be adopted when starting to build a new software system. 

The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index started in the year 2001 and updated once a month.


PYPL PopularitY of Programming Language

The more a language tutorial is searched, the more popular the language is assumed to be. It is a leading indicator. The raw data comes from Google Trends.
If you believe in collective wisdom, the PYPL Popularity of Programming Language index can help you decide which language to study, or which one to use in a new software project.

The PYPL PopularitY of Programming Language Index is created by analyzing how often language tutorials are searched on Google. The index is updated once a month.


Java is the most widely popular programming language in both Index (PYPL and TIOBE). Java has a 24.2 percent and 20.53 percent developer share in PYPL and TIOBE Index, respectively. Share of Java has increased compare to year before in both index. Java is taking lead by 12.3 percent and 5.92 percent in PYPL and TIOBE Index, respectively in global ranking. In India, Java is ahead by 19.3%. But in US, Java is ahead by only 5.1%.
Python and PHP is at 2nd and 3rd position, respectively in PYPL. In TIOBE, Python is at 5th and PHP is at 6th position. In Both Index, share of PHP has decreased and share of Python has increased. Rank of Python is moved up from 8th to 5th in TIOBE.
With 14.60% percent share, C is 2nd most popular language in TIOBE. 3rd ranked C++ is 7.88% behind C. C is followed by C#. Objective-C is now at number 15 in march 2016 compare to number 3 in march 2015.

Sources:- http://www.tiobe.com/tiobe-index/
                http://pypl.github.io/PYPL.html
               https://en.wikipedia.org/wiki/Measuring_programming_language_popularity
               http://githut.info/
              http://stackoverflow.com/

Wednesday, 27 July 2016

Different places to store data while a program is running.

Shop Online

It's useful to visualize  how data store while the program is running—in particular how many types of memories available to store program data. There are five different places to store data:

1. Registers. This is the fastest storage because it exists in a place different from that of other storage: inside the processor. However, the number of registers is severely limited, so registers are allocated as they are needed. You don't have direct control, nor do you see any evidence in your programs that registers even exist (C & C++, on the other hand, allow you to suggest register allocation to the compiler. This is the reason that is why C & C++ has faster execution than other programming language).

2. The stack. This lives in the general random-access memory (RAM) area, but has direct support from the processor via its stack pointer. The stack pointer is moved down to create new memory
and moved up to release that memory. This is an extremely fast and efficient way to allocate storage, second only to registers. The Java system must know, while it is creating the program, the exact
lifetime of all the items that are stored on the stack. This constraint places limits on the flexibility of your programs, so while some Java storage exists on the stack—in particular, object references—Java objects themselves are not placed on the stack.

3. The heap. This is a general-purpose pool of memory (also in the RAM area) where all Java objects live. The nice thing about the heap is that, unlike the stack, the compiler doesn't need to know how long that storage must stay on the heap. Thus, there's a great deal of flexibility in using storage on the heap. Whenever you need an object, you simply write the code to create it by using new, and the storage is allocated on the heap when that code is executed. Of course there's a price you pay for this flexibility: It may take more time to allocate and clean up heap storage than stack storage (if
you even could create objects on the stack in Java, as you can in C++).

4. Constant storage.Constant values are often placed directly in the program code, which is safe since they can never change. Sometimes constants are cordoned off by themselves so that they can be optionally placed in read-only memory (ROM), in embedded systems.

5. Non-RAM storage. If data lives completely outside a program, it can exist while the program is not running, outside the control of the program. The two primary examples of this are streamed objects, in which objects are turned into streams of bytes, generally to be sent to another machine, and persistent objects, in which the objects are placed on disk so they will hold their state even when the program is terminated. The trick with these types of storage is turning the objects into something that can exist on the other medium, and yet can be resurrected into a regular RAM-based object when necessary. Java provides support for lightweight persistence, and mechanisms such as JDBC and Hibernate provide more sophisticated support for storing and retrieving object information in databases.

courtesy:-Bruce Eckel

Sunday, 24 July 2016

Emergence of Java, is not just another programming language.

Programming is about managing complexity: the complexity of the problem you want to solve, laid upon the complexity of the machine in which it is solved. Because of this complexity, most of our programming projects fail. And yet, of all the programming languages of which people aware, none of them have gone all-out and decided that their main design goal would be to conquer the complexity of developing and maintaining programs.[1] Of course, many language design decisions were made with complexity in mind, but at some point there were always some other issues that were considered essential to be added into the mix. Inevitably, those other issues are what cause programmers to eventually “hit the wall” with that language. For example, C++ had to be backwards-compatible with C (to allow easy migration for C programmers), as well as efficient. Those are both very useful goals and account for much of the success of C++, but they also expose extra complexity that prevents some projects from being finished (certainly, you can blame programmers and management, but if a language can help by catching your mistakes, why shouldn’t it?). As another example, Visual BASIC (VB) was tied to BASIC, which wasn’t really designed to be an extensible language, so all the extensions piled upon VB have produced some truly horrible and unmaintainable syntax. Perl is backwards-compatible with Awk, Sed, Grep, and other Unix tools it was meant to replace, and as a result is often accused of producing “write-only code” (that is, after a few months you can’t read it). On the other hand, C++, VB, Perl, and other languages like Smalltalk had some of their design efforts focused on the issue of complexity and as a result are remarkably successful in solving certain types of problems. 

What has impressed people most as they have come to understand Java is that somewhere in the mix of Sun’s design objectives, it appears that there was the goal of reducing complexity for the programmer. As if to say “we care about reducing the time and difficulty of producing robust code.” In the early days, this goal resulted in code that didn’t run very fast (although there have been many promises made about how quickly Java will someday run) but it has indeed produced amazing reductions in development time; half or less of the time that it takes to create an equivalent C++ program. This result alone can save incredible amounts of time and money, but Java doesn’t stop there. It goes on to wrap many of the complex tasks that have become important, such as multithreading and network programming, in language features or libraries that can at times make those tasks easy. And finally, it tackles some really big complexity problems: cross-platform programs, dynamic code changes, and even security, each of which can fit on your complexity spectrum anywhere from “impediment” to “show-stopper.” So despite the performance problems we’ve seen, the promise of Java is tremendous: it can make us significantly more productive programmers. 

One of the places people see the greatest impact for this is on the Web. Network programming has always been hard, and Java makes it easy (and the Java language designers are working on making it even easier). Network programming is how we talk to each other more effectively and cheaper than we ever have with telephones (email alone has revolutionized many businesses). As we talk to each other more, amazing things begin to happen, possibly more amazing even than the promise of genetic engineering.

In all ways—creating the programs, working in teams to create the programs, building user interfaces so the programs can communicate with the user, running the programs on different types of machines, and easily writing programs that communicate across the Internet—Java increases the communication bandwidth between people. People think that the results of the communication revolution may not be seen from the effects of moving large quantities of bits around; we shall see the true revolution because we will all be able to talk to each other more easily: one-onone, but also in groups and, as a planet. People have heard it suggested that the next revolution is the formation of a kind of global mind that results from enough people and enough interconnectedness. Java may or may not be the tool that foments that revolution, but at least the possibility has made me feel like people are doing something meaningful by attempting to teach the language. 



Inspired by Bruce Eckel.

Tuesday, 15 March 2016

How can professionals act as force multipliers of the existing government set up in India?

At present scenario, professionals are most required in government. Because the
government system lacking qualified professionals. Qualified professionals either
working in MNCs or migrated abroad. Professionalism in governments in India
definitely can be force multiplier.
Now question arise here, why professionals are required in government set up in
India?
Today most of the government organisations known for its irresponsibility, delay in
work, no transparency, no work progress tracking, and no accountability.
Professionals can be helpful in eradicating such kind of problems in government
organisations.
Let us, we try to find how professionals can be helpful in a better government set up.
1.
Training of less skilled employees in organisation :- A proper training is
must for all employees in any organisation for better productivity. For example, a
postman in a post office does not know proper sorting of mails, he wouldn't be able to
deliver posts on time. While a well trained postman can sort post in less time and can
deliver on time.
So, professionals can train and monitor employees for better work. Professionals can
organised seminars and workshops for training.
2.
Use and awareness of technologies :- Professionals are aware of latest
technologies and tools available for better output. Technologies can be used to
monitor, secure and tracking of work in organisation. Now-a-days most of the
organisation should be be digitized. Technologies can also be implemented to
transparency, accountability and other purpose.
3.
Decision making :- In existing government set up decision making is very
delayed. Some time many policies required quick decision. No one took the risk for
making any decision. Professionals can be helpful in quick decision making.
4.
Better utilization of talent pool :- Professional can identify the talented
person in organisation. Since, they exist in minimum number, they should be utilized
properly and they can help others.
5.
Participation :- There should be proper provision of participation of men and
women employee as well as civilians (if needed).
6.
Optimum utilization of resources:- Professionals can be very useful in
optimum utilization of available resources. It should be identified that which/who is
buzy and which/who is lazy.
7.
Planning :- Planning is the most required step in any success story. If
something is planned professionally, It has more chance to succeed. There are several
tools available (Key Performance Indicators (KPIs)) to monitor planned and actual.
8.
Manage customers/civilians expectations :- Enough attention is placed on
managing the customer’s or civilian's expectations prior to delivering the
project/policy. By ensuring that everybody involved in the project delivery process
has a clear understanding of the scope, risks, deliverable and acceptance criteria
associated with projects there is likely to be less project issues, less slippage and
fewer budget overruns.
9.
Create a productive work environment :- It’s about creating a productive
working environment where employees can share ideas, tap into each other’s
knowledge and limit the impact of any absent resource. This is where some form of
project and team collaboration is important, as it is commonly recognized that
working together can accomplish more. By providing your project team members
with a platform where they can work in synergy, share ideas and share knowledge;
and where each individual team members contribution is focused on a common goal,
your business will quickly benefit from greater innovation, better problem solving
and greater efficiency in project delivery.
10. Tracking current productivity and utilization :- It is old phrase which I
have read in my software engineering book that “ You can’t manage what you can’t
measure”. But it is too true for any organization. Some people work less and produce
more while some people work more and produce less. Everything should be planned
and well managed.
11. Set target and time frame:- Our target should be clear and work in the
direction of target. So, that we can achieve our goals. Time frame is key factor for
any project. Because some projects/policies become useless if it doesn't have
completed/delivered on time.

Apart from these some mentioned point many other factors can act as productivity
booster for government. These point are not only conceptual. Many MNCs (like
Google, Facebook) are working with these concepts and going higher. And not only
MNCs, some of government sectors (Banking sector) has also adopted these
concepts.

Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...