Archive for 'Fundamentals'

Revisiting Algorithms: Fibonacci Sequence

I am starting new posts that visit many of the familiar algorithms that we have already learnt in the past. I will use C# as the primary language to represent these algorithms. To start, let us start with a very simple example, Fibonacci Series. 0,1,1,2,3,5,8,13,21,..etc are typically called Fibonacci numbers. These numbers were well known in ancient India. In short, each number is a sum of the previous two numbers with the seed values being 0, 1. The following is the C# code that outputs a series of Fibonacci numbers with input being the number of Fibonacci numbers to generate.

   1:  public static int[] GenerateFibonacciNumbers(int n)
   2:  {
   3:      int[] arr = new int[n];
   4:      arr[0] = 0;
   5:      arr[1] = 1;
   6:      for (int i = 2; i < n; i++)
   7:      {
   8:          arr[i] = arr[i - 1] + arr[i - 2];
   9:      }
  10:      return arr;
  11:  }

A side by side comparison of Java and .Net acronyms

Often times, we jump from one platform to another while working on projects. This is a simple concise table which compares Java and .Net and explains the meanings of the various acronyms.

 

Java .NET Description
Java C#, VB.NET etc programming language.
Java virtual machine (JVM) Common Language runtime (CLR) JVM compiles bytecode into native executable instructions.
Java Enterprise Edition (JEE) ASP.NET, Sharepoint, WCF, etc., Enterprise web development.
Java FX Silverlight, WPF Rich applications
Java Development Kit (JDK) .Net framework multiple versions are supported.
Spring MVC, Struts 2 ASP.NET MVC, Spring.Net MVC MVC frameworks.
JSP pages ASPX pages pages that serve dynamic content form server.
web.xml web.config web application configuration files.
Eclipse based tools Visual Studio Team System IDE for development
Apache, Tomcat, JBoss, etc., IIS web server
Maven, Ant MSBuild, Nant Build frameworks
Junit Nunit unit testing frameworks

 

Please let me know if I missed any obvious ones or if you notice any incorrect comparisons.

Learning new programming language

This was my reply to a question posted on StackOverflow about learning new languages. You can find the question and more discussion at

http://stackoverflow.com/questions/1041687/learning-a-language-while-on-a-project

I would like to mention ALT.NET here

Self-organizing, ad-hoc community of developers bound by a desire to improve ourselves, challenge assumptions, and help each other pursue excellence in the practice of software development.

So in the spirit of ALT.NET, it is challenging but useful to reach out of your comfort zone to learn new languages. Some things that really helped me are as follows:

  1. Understand the history behind a language or script. Knowing evolution helps a lot.
  2. Pick the right book. Research StackOverflow and Amazon.com to find the right book to help you ease the growing pains.
  3. OOP is fairly common in most of the mature languages, so you can skip many of the chapters related to OOP in many books. Syntax learning will be a gradual process. I commonly bookmark some quick handy guides for that.
  4. Read as many community forums as possible to understand the common pitfalls of the new language.
  5. Attend some local meetups to interact with the community and share your pains.
  6. Take one pitch at a time by building small not so complicated applications and thereby gaining momentum.
  7. Make sure you create a reference frame for what you need to learn. Things like how security, logging, multithreading are handled.
  8. Be Open minded, you can be critical, but if you hate something then do not learn that language.

Finally, I think it is worthwhile to learn one strong languages like C# or Java, one functional language and one scripting language like ruby or python.

These things helped me tremendously and I think it will help all software engineers and architects to really gear for any development environment.

5 must have books for programmers

Every programmer should have these books on his or her shelf.  The authors of these books cover a wide range of material in the form of design patterns, real-life experiences, code samples,  and software construction. They present the material really well in a platform agnostic way. If you are serious about your career in computer programming, these books can help you build great reliable software. These books are not ranked and are in no particular order. I linked each of these books to Amazon but you can find them at other stores as well.

 

Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John M. Vlissides
Code Complete by Steve McConnell
Pragmatic Programmer by Andrew Hunt, David Thomas
Refactoring: Improving the Design of Existing Code by Martin Fowler
The Art of Computer Programming: Fundamental Algorithms by Donald E. Knuth

Solid Architecture: S.O.L.I.D Principles

Domain Driven Design (DDD) and Service Oriented Architecture (SOA) can basically be defined as aggregate functions of principles, patterns, and most importantly Object-oriented concepts. In order to build a highly scalable and reliable architecture, it is very important for us to follow these important design patterns, and when they are coupled with a set of good principles, results in a great software. One such set of rules that should not be overlooked are S.O.L.I.D principles, first coined by Robert C. Martin.

Single Responsibility Principle (SRP) A class should have only one reason to change.
Open/Closed Principle (OCP) Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification
Liskov Substitution Principle (LSP) Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T.
Interface Segregation Principle (ISP) The dependency of one class to another one should depend on the smallest possible interface.
Dependency Inversion Principle (DIP) Depend upon abstractions (interfaces), not upon concrete classes.

There are plenty of resources available on the Internet on these principles. So far, I really liked Steven Bohlen’s video presentations on dimecasts.net.

Also, I recommend the following books to get a good picture on building overall good software.

codecomplete agilerobert

English Manual for Technologists

For those of us who are not good technical writers, here is a great book that continues to help me a lot. It is by William Strunk Jr., and is called ‘Elements of Style’. You can order it from Amazon if you like reading a hard book, and this book is online on bartleby.

 

image

Rules Engines

Rules Engine can be defined as a framework that is used to manage and automate business rules. It is very useful to have such a framework in place specially when these business rules need to be modified frequently. Often, we as software architects need to design our applications to handle such frequent change in business rules. There are several rules engines available in the market. Some of the rules engines  available are;

.Net

  • Biztalk Server
  • ILog Rules for .Net

Java

  • Jess
  • Jboss Rules
  • ILog JRules

Ruby

  • Ruleby
  • Ruby Rools

Most of these engines, or frameworks use Dr. Charles Forgy’s Rete Algorithm. Rete is Latin for Net or network. It is a pattern matching algorithm comprising of rule compilation and rule execution. Before adopting this in your enterprise, every Architect must understand this algorithm to know the various architectural implications that it can have on the overall system like performance, scalability, etc., Also, just because you implement a rules engine, it does not mean that you can put all your business requirements and rules inside it, as some of the business rules cannot be expressed. Most often, these business rules cannot be expressed by the business users, and have to be coded by programmers.

Ethics in software engineering

This topic has a lot of importance and relevance in today’s world, which is why it is my first post on my blog. Software engineering is going through lots of cycles and changes. The way I used to do things 10 years ago is no longer true. There are several changes in terms of culture, with the advent of technology enablers like cloud computing, architectural patterns like service oriented architecture, etc., but the fundamentals never change.

One such fundamental area is ethics in software engineering. It holds a lot of value in the way we practice software engineering, design, and architecture, but is sometimes ignored. There is a code of ethics in software engineering and professional practice jointly approved by ACM and IEEE. Here is a short version of this code from the ACM:

Software engineers shall commit themselves to making the analysis, specification, design, development, testing and maintenance of software a beneficial and respected profession. In accordance with their commitment to the health, safety and welfare of the public, software engineers shall adhere to the following Eight Principles:

1. PUBLIC - Software engineers shall act consistently with the public interest.

2. CLIENT AND EMPLOYER - Software engineers shall at in a manner that is in the best interests of their client and employer consistent with the public interest.

3. PRODUCT - Software engineers shall ensure that their products and related modifications meet the highest professional standards possible.

4. JUDGMENT - Software engineers shall maintain integrity and independence in their professional judgment.

5. MANAGEMENT - Software engineering managers and leaders shall subscribe to and promote an ethical approach to the management of software development and maintenance.

6. PROFESSION - Software engineers shall advance the integrity and reputation of the profession consistent with the public interest.

7. COLLEAGUES - Software engineers shall be fair to and supportive of their colleagues.

8. SELF - Software engineers shall participate in lifelong learning regarding the practice of their profession and shall promote an ethical approach to the practice of the profession.

If you are interested in the longer version, you can visit the ACM site; Full version. While all the points above are important, point 7 is a more interesting point which warrants a separate post.

Further, each company has its own demands and requirements when it comes to ethics. I urge every IT manager to use this code as a basis to draft a more relevant and specific code of ethics, that suits his engineering practices. He then needs to educate his team on the benefits of the code. It is a moral responsibility of every software engineer to adhere to these principles.