Friday, May 24, 2013

Linux distributions


Linux is one of the leading open source projects in the world, but what is Linux, we have many "Linuxes" - red hat, blue cat, ubuntu, suse so what does it means that all of them are Linux. well, Linux is a standard there are set of rules that if you wish to be Linux you have to satisfy, these rules are in two different standards - POSIX and GNU, POSIX talk about rules for the core of the operating system mainly the kernel and stands for portable operating system interface and GNU stands for gnu not Unix specify applications that complete the Unix standard. Every distribution has to implement these standards so it can be called Linux.
One of the rules is the license of Linux that should be open source and free to download. And usually each Linux distribution builds from a Linux program. The distributers download the code and then add and modify the code for a new Linux, this new version usually called Linux distribution.
I would like to present some of the popular distribution of Linux:

Ubuntu: Ubuntu is distributions that focus on the user and try to provide him easy interface for his work, many feature like plug & play and easy installation are provided in ubuntu. 
Today many users that wish to work at home with Linux work with Ubuntu and it became real (small) competitor for windows.

Red Hat: The biggest distribution for enterprise Linux, the main advantage of the red hat distribution is application called RPM that allow you to update software automatically and in very easy way. the red hat is of course free of charge but if you wish you can be connected to the red hat servers and update your Linux automatically for money. this is highly important feature for enterprise companies who has large number of servers and need to maintain them constantly and be up to date as soon as possible due to critical systems that run on these Linux servers.

Suse: also well known large distributer of Linux, developed by novel and consider to be very reliable and effective Linux distribution. One of the major advantages of Suse Linux is the interoperability with Windows and Microsoft technology so working in this hybrid environment becomes much easy.

Blue cat: this Linux distribution is used for embedded and real-time system it allows you to configure your kernel and customize it to be suitable for embedded systems, remove the mouse and keyboard from the kernel. 

Monday, May 20, 2013

Preform background operation with swing worker

Hi,
I think that one of the suffering things in UI is making a progress bar, you need to update it constantly while the operation is invoked by another thread and calculate the progress of the task.
From java 6.0 we have a new utility that help us with that called SwingWorker.
SwingWorker is an abstract class that you can extend and the abstract method called doInBackground  that allow it to preform background operations. SwingWorker also can update the progress bar with the process method and by firing events for changes in the progress bar.
Let's see an example
In our example, we would like to send mails in the background for large number of users that defined in the Swing application. once the submit button is press the application will send the content of the mail to all the users, let's see the code of the application:

public class Application extends JFrame {
 
  // The UI Components
  private JProgressBar progressBar;
  private JTextArea mails;
  private JTextArea message;
  private JButton sendMails;
  private JLabel status;
 
  public Application(){
   setSize(600, 600);
   message = new JTextArea();
   JPanel rightPanel = new TextAreaPanel(new JLabel("message"), message);
   add(rightPanel, BorderLayout.EAST);
   mails = new JTextArea();
   JPanel leftPanel = new TextAreaPanel(new JLabel("mails"), mails);
   sendMails = new JButton("send it!");
   add(leftPanel, BorderLayout.WEST);
   add(sendMails, BorderLayout.NORTH);
   progressBar = new JProgressBar();
   progressBar.setStringPainted(true);
   add(progressBar, BorderLayout.SOUTH);
   sendMails.addActionListener(new ActionListener() {
  
  @Override
  public void actionPerformed(ActionEvent e) {
   String addresses = mails.getText();
   String[] add = addresses.split("\n");
   SendMailsWorker worker = new SendMailsWorker(message.getText(), add);
   // A property listener used to update the progress bar
      PropertyChangeListener listener = 
                                 new PropertyChangeListener(){
        public void propertyChange(PropertyChangeEvent event) {
          if ("progress".equals(event.getPropertyName())) {
            progressBar.setValue( (Integer)event.getNewValue() );
          }
        }
      };
      worker.addPropertyChangeListener(listener);
   worker.execute();
   
  }
 });
  }
  
 
  // The main method
  public static void main(String[] args){
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        Application app = new Application();
        app.setDefaultCloseOperation(EXIT_ON_CLOSE);
        app.pack();
        app.setVisible(true);
      }
    });
    System.out.println("finish main");
  }
}

// and another class for handling the panel is
public class TextAreaPanel extends JPanel{

 public TextAreaPanel(JLabel label, JTextArea text) {
  text.setPreferredSize(new Dimension(120, 120));
  add(label, BorderLayout.WEST);
  add(text, BorderLayout.CENTER);
 }
}

The action of sending the mail should be in the background, therefore, we should create a swing worker that handle the task, let's see it
public class SendMailsWorker extends SwingWorker {

 private final String message;
 private final String[] addresses;

 public SendMailsWorker(String mes, String[] mails) {
  message = mes;
  addresses = mails;
 }

 @Override
 protected Integer doInBackground() throws Exception {
  int matches = 0;
  for (int i = 0, size = addresses.length; i < size; i++) {
   // Update the status: the keep an eye on thing
   publish("send mail to: " + addresses[i]);
   matches += sendMail(message, addresses[i]);
   setProgress((i + 1) * 100 / size);
  }
  return matches;
 }

 private int sendMail(String message2, String string) {
  // sending the mail
  try {
   Thread.sleep(10000);
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return 1;
 }

 @Override
 protected void process(List chunks) {
  for (String message : chunks) {
   System.out.println(message);
  }
 }
 
 @Override
 protected void done() {
  System.out.println("finish sending mails");
  super.done();
 }
}
as you can see from the code, the operation of sending the mail is done by the SendMailWorker that extend SwingWorker. the method doInBackground preform the operation and set the progress so than you can write to the console or to any other place the progress of the writing. I think SwingWorker is very nice utility that simplify the ability to preform background operations.

Sunday, May 12, 2013

What is my problem with Microsoft technology

As an architect that working in the software industry almost 15 years I came across many technologies some are great and some of them are not so great...
In this post i would like to refer to technologies that came from specific vendor - Microsoft.
As you probably can see from my blog name i'm a java person and i don't have a lot of experience in Microsoft technology. I did some projects that related to .NET and Microsoft but i'm not expert.
Generally, i can say that .NET is pretty good framework, some of the things i like some are not but I think this framework contribute a lot to the software industry.
However, The Microsoft technology has one big flow, it refuses to collaborate with many other technologies that exist in the world. for example, last week i lectured about ALM and architecture and one of the listeners ask me if TFS (the Microsoft ALM tool) can work with subversion. The ALM guy that run the user group ask her why she would like to use subversion you can use Microsoft tools instead. this is of course a Microsoft user group...
The philosophy of we will provide you anything that you need and you can't use any other technology is annoying. I personally believe that each framework, tool or language are means to do my job better and every one of them should be used differently according to the circumstances.
If you are eating steak you should do it with fork and knife and not with spoon. it doesn't mean the spoon is redundant t just means that it doesn't feet for me right now.
No company not matter how big it is can't provide solutions to all the use cases in the world, therefore, good technology is a technology that can integrate easily with other technologies.
More than that, Microsoft prove that when it is important for them they can do it better than anyone else, you can see it in the integration inside Microsoft technology and also in there cloud solution, azure.
So i hope Azure is a good start in this direction and hopefully Microsoft technology will be more open for integration with other technologies in the near future.  

Tuesday, May 7, 2013

My lecture about SOLR in the SDP

Hi,
Yesterday i was lecturing about SOLR in the SDP, it's the larget confrence of sela with international speakers about many technology mainly in Microsoft technology - www.seladeveloperpractice.com 
The presentation of Solr can be found here.
Enjoy :-)


Wednesday, May 1, 2013

cloud & ALM

I wrote nice presentation about the changes of the cloud and the implications about ALM and architecture.
You can find the presentation here:

enjoy!

Thursday, April 25, 2013

The NoSql mini revolution

Hi all,
the latest trend in the software industry is the big data and noSQL movement.
since today many applications provide services to a lot of clients and have problem in scaling more and more software vendor considering giving off the sql transactions and choose NoSQL DB.
But i think lately due to this revolution we have another small revolution that provide good back wind for the NoSQL movement - using NoSQL DB just becouse it's easier.
Using SQL DB is something that we use to it but it's not simple. you have to write SQL queries, optimize them and use data structure that very diffrent from your program.
SQL queries are not predictable, i had SQL queries that in some cases took 15min and some cases the all night. now you need to open the execution plan and start understanding how the database server is working.
So sometimes it's very easy to use NoSQL DB usually a document DB that provide you easy working API and simple work if you don't need complicated stuff. and you use it not for sharding just for convnience.
I think it's very refreshing and really contribute a lot for the big data revolution.

Saturday, April 20, 2013

What is the best language programming

I think programmers fight on this questions like football fans cheers there group.
more than this often languages that consider to be the best language like cobol after few years consider to be very problematic languages. i believe also that many good languages are not consider good since they don't have good PR. in this post i will try to tell my opinion about what is the best programming languages and write my criteria on it. as you will see, well you probably already guessing is not a world of black and white and the answers are not so deterministic, however, i think i can spread some light on this issue.
First is important to say that programming language is a tool and like any tool it depends on the task that you need to preform, not all the applications are the same so the language should be feet to the task that you need to preform. of course, that rich frameworks and strong community are also a good criteria for good language. there are some languages that very good in specific thing, for example, perl is very good in text processing. logic languages like prolog good in artificial intelligence and so on.
also when you talk about good languages the question is good in what?
C & C++ good in performance and optimization
VB consider to be good in rapid application development, but notice that languages that belong to the .NET framework limit you to windows so of course they have some advantage working on windows.
But i think the most important thing in programming language is a language that help the programmer not to write bad code. for example, C++ put all the responsibility on the programmer. I think it's not good, good code is a code that prevent the user who use it to make mistakes and guide him to write good separate code.
The disadvantage for this issue is that sometimes you need to write more code since this is the right way to do it. I think java is a great example for such language and this is why i think java is very good programming language. let me provide an example: in java we don't have pointer to function, if you wish to send pointer to function you need to create interface with one method, implement in a class and than this object will be the function itself. java do it since in java everything is an object. this is why java is a pure object oriented language. but sometimes it requires more work even for simple cases. this is why the JCP try to add more functional attributes to java. however, all the functional languages has very unclear syntax and i think we should be very careful on this issue.
so what is the best language, well if you wish to write big server enterprise applications on cross platform probably java is your answer. in places that you wish to avoid the overhead of java you may use other languages and integrate them in java. but i think the architectures of java keep there minds helping the programmers working in the right way.