Developing hybrid mobile apps with Phonegap, AngularJS, Bootstrap

In this post I am going to talk about developing hybrid mobile apps with Phonegap, AngularJS, Bootstrap. In my post Develop mobile applications using web development skills, I pointed out a list of possible frameworks which can be used to create a hybrid mobile app. My favorite choice so far is using Cordova/Phonegap (Read my post on my opinion about Cordova/Phonegap) in combination with a hybrid app development framework. In my previous mobile applications I have developed, I used to use jQuery mobile as my framework of choice for developing the UI of my apps. Nowadays, I have switched to another combination, which is:

Cordova/Phonegap + AngularJS + Bootstrap

The hybrid mobile app architecture with Phonegap, AngularJS, Bootstrap looks like this:

The presentation layer is built with Bootstrap framework, the app domain is modelled using AngularJS, and the is packaged using Cordova/Phonegap to a native app. Let us go through the components of this hybrid mobile app architecture and describe them.

Bootstrap

Bootstrap is a mobile-first responsive front-end framework. What this mean? Bootstrap has an easy to use responsive grid which allows you to position your layout in a well structured responsive way. As the framework is built with mobile use in mind, it responds well to different screen sizes and adapts the layout of the app easily to different screen sizes. This is a good possibility to use the very same implementation for tablet and mobile devices of different screen sizes. And it is not only the grid that makes it special. It helps you manage typography, responsive images, forms, form validation messages, notification messages, responsive tables, and a good number of UI components. You can download it from getbootstrap.com.

AngularJS

AngularJS

AngularJS

A very powerful, full-featured JavaScript MVW framework. With AngularJS framework, you can give a structure to your app domain model and manage your app logic in a very flexible way. Everything is organized around a model which is displayed through a View. Views can be well structured templated HTML code styled and organized using Bootstrap. Controllers organize the communication between the View, Services, and all other parts. The framework supports a good routing mechanism, which can also be extended by other extension libraries for more powerful functionalities. There are a plethora of extension libraries for AngularJS which add value to the framework by filling in the gaps of the framework. You can get AngularJS from angularjs.org.

 

Cordova/Phonegap

Cordova is an Apache project which creates an underlying platform for developing multiplatform mobile applications. In our case, it makes possible the AngularJS+Bootstrap web app to be packaged to a native mobile app which can be published to the mobile markets and be instlalled in mobile devices. Adobe PhoneGap is a distribution of Cordova.

Basically what Cordova does is to make possible the web app to run inside a WebView component of a native app, we can say it as a native package of a web app. You can do the packaging using Cordova Command Line Interface (CLI) or using Adobe PhoneGap Build which does not require any installations.

The most powerful feature of Cordova in my opinion is the extension possibility by plugins. By installing specific plugins, you get access to device’s hardware such as camera, compass, geolocation, as well as other device specific APIs such as contacts, media, notifications, etc. Very powerful plugins such as barcode reading, push notifications, and many more, can give your application good features by writing few lines of code.

The development process

As we described the architecture parts, let us start with the process of developing hybrid mobile apps with Phonegap, AngularJS, Bootstrap. We start with creating a sample application  which shows you your current location coordinates and demonstrate the development process. The easiest way to start the app development is by creating initial template using Cordova/Phonegap CLI. We do this through this command (if you do not have cordova cli installed, here is the link showing how to do it: https://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html)

The create command requires 3 arguments:

  1. The directory name to be created for generation of the project, in our case “blogSample”
  2. The second argument is the project identifier, in our case “com.ariancelina.blogSample”. Usually it is used as a reversed domain name identifier
  3. The third argument is the display title of the application, in our case “BlogSample”

In this sample code, I used phonegap to create the app. The command equally applies to cordova as well.

If you already had phonegap installed and the app was created successfully, inside blogSample directory you should have a config.xml file and four other directories (hooks, platforms, plugins, and www). Platforms folder contains builds for specific platforms, plugins directory contains installed plugins, and WWW directory contains all our web code (AngularJS + Bootstrap + other files).

To read our location coordinates we need to install the Geolocation plugin (Find the list of plugins) and we do that by executing this command:

Now that we have the initial structure, we need to add platforms to which we want to deploy, but to do that, we need to be inside out app directory, which in our case is blogSample. Adding ios platform is done using the command

After the platform is added, we can build our app using

We can repeat last two commands for all other supported platforms like android, windows phone, etc.

If we want to test our app, we can go to directory blogSample/platforms/ios and lunch BlogSample.xcodeproj and run the app in simulator or existing device.

We have our platform set up, now let us add the AngularJS and Bootstrap files. After we download these (download AngularJS as a zip file so you get all parts of it), we put inside blogSample/www/js directory AngularJS and Bootstrap js files: jquery-1.11.2.min.js (jquery is a dependency of bootstrap and can be downloaded from jquery.com)angular.min.js, angular-route.min.js and bootstrap.min.js. Inside blogSample/www/css directory we put bootstrap.min.css and bootstrap-theme.min.css files. And the last part here is to link these files in our main file index.html. We put css code in head section:

and near the closing body tag we link the javascript files

Now we have the setup ready and we can start coding the logic. We need three things to define to make it work, we need an angular route config which allows us to navigate from page to page, then we need an angular controller, and a view which will display the user his/her current location.

We start with the app.js file which contains the initialization of the js app. This file also is the place where the initialization events are placed. In our case, it looks like this:

We start by defining our angular app, blogSample (line 1). We initiate it and  define the modules which we need (ngRoute, ui.bootstrap). There are other interesting things happening here. As we are used to use jquery ready function to react when the page is loaded and ready for use, here we have onDeviceReady event which is fired when the app is loaded and we can start using it. Inside this event, we will get the current position of the device through this line of code

The getCurrentPosition function which gets the current latitude and longitude of the device, needs two functions as parameters, first being the function that is called if the current location can be obtained successfully, and the latter for errors. The error function is used to report the unavailability of the location. The success function is used to read the coordinates and bind them to our angular app, blogSample through this function

Now that we have our app setup ready, let us define two views, one about page and the other showing location information. Showing the coordinates inside the view is done using

AngularJS will substitute the values inside curly braces with current coordinates set in onSuccess function. But views do not access application level values. We usually link a controller with a view, and view is limited to the scope of that controller, so we need to define a controller to glue the coordinates to the view. The controller will look like:

and finally we add the router configuration to bind the controller to the view and enable the user moving between pages. The router has this code:

The router part defines one default url and ‘/about’ url. The default url ‘/’ binds to main.html view, and the ‘/about’ url binds to about.html view.

Now that we have all the building pieces in place, we need to add the reference of last created files in index.html and the references will look like this:

Now that everything is on place, we can deploy our app to the phone for testing, or run it in a simulator. Running the application is different depending on the platform. You may use the simulators that can be started from phonegap, by xcode, eclipse, or android studio, but for any serious app development, I would strongly suggest you try your app in a real device. I will not go into details about deployment as it is out of scope of this post, but in the simplest scenario, you may go to platforms folder inside  your phonegap project folder, and open the project of the specific platform and run the project from the respective ide.

The complete source code of this application can be found on GitHub https://github.com/acelina/phonegapWithAngularJs, you may download it and try it on your computer.

What is the mission of a software developer

Nowadays, there is a great demand for software development out there. The world needs software solutions just about anything. From planning and running complex business and industrial services to planning and running your day. From execution of mission critical operations to playing for fun, almost everything is backed by a software. There are millions of software developers out there and yet the global need for them is not about to be met. The world needs a lot more software developers, but seriously, why do we need them, what is the mission of a software developer that is so important to the world economy?

Let us analyse first how a software developer grows. Basically, there are two major paths one may follow to be a software developer. One is to have a formal education (be it a university degree, or a formal training program) and acquire the necessary skills to develop software, and the other is to be an autodidact and teach yourself using plenty of available resources (books, online courses, articles, tutorials, etc.) about software development.

The self learning approach is very personal and it is hard to generalize the way one teaches himself therefore it is hard to draw conclusions that what process is followed or what the outcomes may be. Also, compared to the numbers, I am sure this group is the minority, and the majority of developers come from a more formal path.

The formal path, however, has a visible indicator how one is being trained in the field of software development. We can have a look at the curricula of many universities and analyze them. We can get a subset of subjects that are covered from most universities, or so to say core subjects,  and they are programming languages, databases, data security, algorithms, maths, web development, etc. (I am not focusing here on training programs as usually they tend to have a narrower focus on one technology or one aspect of it, and rarely on a complete process as universities do). Some universities offer also non computer science complementary courses such as on entrepreneurship, preparing business plans, biology, etc., but only as elective courses that are left on the will of the student if he or she wants to take it.

From the university curricula I have seen, I can draw the conclusion that most of the universities prepare the software developers as pure technical persons who are supposed to solve technical problems related to software development. But is this the reason world needs the software developers that much? Personally, I do not agree with this, and I keep asking myself the question:

What is the mission of a software developer?

Let us try to answer this by trying to find the answer to this question: What does a software developer do after the graduation? I can think of several answers to this:

1. Industry path: He or she is employed by a company who needs software solutions for their business needs (be it a software developer company, a bank, an engineering company, a distribution business, whatever…) and he/she works there trying to create software solutions for the needs of the company.

2. Academic path: He or she may decide to pursue further studies and be a researcher who continues to contribute to academia by teaching and to the knowledge by researching unknown solutions for existing technical, real life or business problems.

3. Entrepreneur path: He or she creates a solution for a real life problem or a business problem, makes a business out of it, and creates an enterprise which runs a business by providing a software solution for a business problem.

Of course it is not easy to sum up all available paths to follow, but in my opinion these three cover the major available paths to follow for a computer science graduate.

Now what can I see from these choices is that, none of them are about solving technical problems purely. What I can also conclude is that, solving a real life or business problem is what turns out to be the real reason why we need so many software developers today. From this, I can confidently say that

The mission of a software developer is to solve real life and business problems.

You may say that is something we know and it is obvious, what is the problem about this? Well, I have a lot of contacts with different developers, experienced ones and want to be ones, university trained and autodidacts. I am teaching programming courses myself on a university level and professional level for over 6 years now, and I have had the opportunity to deal with over 1000 students up to now. What I can see is that, software developers see themselves as technical persons who are there to solve technical problems and they do not care about the business world. All they are interested is that how a technology or a framework works and how they can use or advance it. That is it. They care about code quality, they care about unit testing, they care about code reuse, and lots of other technical characteristics of the software, but rarely they discuss about how usable their applications are, or how efficiently they optimize a business problem their software is addressing or what business value they have delivered with the software they have built. I am not saying that technical characteristics are unimportant, far from it, we should always strive to write the best quality code we can, according to best industry standards, using best practices, and best patterns we know. I am just stating that the most important thing is we deliver value with software. If there is no value, there is no point having unit tests, most clearly written code, or bug free code, as it will not be used.

But perhaps this is not their fault as the education system they are following is not preparing them to think in that way, and that is where our duty as computer science teachers come to a focus. It is us, everybody who teaches a computer science related subject, be it a university course, an online course, or tutorial series, we should communicate the idea that technology is there to solve real life and business problems. I do think that we should not grow technical persons who write code, but we should teach them to be problem solvers who provide value with their solutions.

What do you think? Leave a comment and let’s discuss about it. If you agree with my opinion and think this is a valuable point, please share it so it reaches a broader audience.

Outputting json data with php

This is going to be a very short post, but could be of use if you did not know about this

Many times, for the purpose of demonstration when I teach AJAX requests to my students, I see the need to have a sample json dataset for easy consuming through AJAX requests. So basically what I want is to output an array of some JSON objects so we can consume let’s say using jquery and display them. I have found some examples, but strangely, none of them was appropriate for using in examples (they either had too much data that confused students, or had a complicated structure).

Usually, what first comes to our minds is that we need a Web Service for outputting json data with php, or perhaps even a REST service. No, for such an easy thing, we do not need a web service, we can achieve this with one line of code, yes, one line.

Let us create an array of arrays, where each array will hold the data of some famous cars:

If we have such an array of arrays, this could easily be translated to a JSON array with JSON objects inside it. The one line of code that we need to do this transformation is:

The result returned will be:

I have published this code to my web site, so if you want to test the result, please go to this link http://18.197.31.180/json.php

The whole code will look like this:

 

Develop mobile applications using web development skills

The need for mobile apps has increased dramatically as their number to. The number of mobile devices in use has passed the first billion more than a year ago and it is still increasing. As mobile use is closing the gap with computer use, the gap of development skills is increasing. Mobile platforms are huge with lot of possibilities and not so easy learning curves. Apple iOS supports Objective-C, C, C++, or Swift programming languages, on the other side, Android supports Java programming language. If you want to target these platforms, you have to be proficient in at least two programming languages, which is not very easy. In addition to that, publishing to both platforms requires you develop and maintain the very same application twice. Cross platform development of hybrid webview applications could be your saviour if your requirements are not graphic or resource intensive. With the performance of the mobile devices of our time, we can easily run mobile web applications packed as native apps with a performance close to native apps (games and resource intensive apps make an exception here). But how do we build such an app?

The answer is, by leveraging our existing web development skills with HTML5, CSS3, and JavaScript and packaging it to a native app. But as we make our mind to use these technologies, we have still many other choices to make. The next one is what framework do we want to use. You can choose to make your UI by yourself, but chances are you will make a not so good feeling UI, or you will use quite a good time with it, so going with a framework is a wise choice here. Some of the choices are:

and this is not the end of the list. There are more choices.

Some of these frameworks offer only a mobile friendly User Interface (UI), and some have UI and packaging features. UI only frameworks are jQuery mobile, AngularJS and Bootstrap combination, Ionic and AngularJS, Kendo UI, and intel XDK. If you choose one of these, you can packaged them to a native mobile app using Apache Cordova or Adobe Phonegap Build. Appcelerator Titanium and Sencha Touch offer their own tools of packaging.

How do you make your choice? I would say your experience and required time to market are most important factors here. Perhaps jQuery mobile can give you the fastest way to put the app together, however, I must say it does not give you a very native user experience. Kendo UI has a good set of UI components but it comes at a price. So, in my opinion. there is no clear line here. The project requirements and available skillset influence the choice.

From my personal experience, I have developed few apps using jQuery mobile, Sencha Touch, and AngularJS with Bootstrap. The latter is my favourite choice, but I am looking forward to expand my horizon and try other frameworks as well. Let’s see what future brings.

PHP Tutorial site

In many of my posts I have shown a positive attitude towards PHP programming language. Although it is not the language I use every day, I do consider PHP as one of the best programming languages for a beginner in web development because I believe it has a fairly easy learning curve. I am now announcing an initiative to create a small PHP tutorial site.

I have been teaching PHP for over four years, and it was always my language of preference when I had to explain web development concepts to someone. I have been teaching it in university level as well as a professional course, and I have seen that students have learned the most important parts of it very quickly.

As a supporting material to my courses, as well as to contribute globally in knowledge sharing, I am creating a new section in my site for PHP tutorials. You can see the page here. This section is going to be dedicated to several tutorials explaining basic concepts of PHP. This is going to be an evolving project of online teaching I am planning to implement during 2015, so I will be adding learning materials continuously. If you don’t want to miss anything, please subscribe, and you will receive them in your email.

A beginners’ guide to web development

If you are reading this post, most probably you have some sort of interest in web development, or even you think about starting to learn about web development. In this post, I would like to show you what path you can follow to be a web developer. This is a beginners’ guide to web development from the perspective of what to learn and how to specialize. This is not a post in which you will learn coding. I just want to point out the what you need to consider before you start learning to code. So, welcome to our dynamic and ever changing world. One of those fast-pace professions with lot of challenges and excitement. So let us define some basic concepts first.

Front End vs. Back End

The initial separation you will feel here is Front End vs. Back End. Let us clarify first what is Frond End and what is Back End.

Front End

Web applications are categorized as distributed applications with a client-server architecture. So, we have a part of code which runs in the client and another part in server. The part of application which is run and rendered in client (most of the time, the client is our web browser) is called the Front End. The most usual technology combination which is used to develop for Front End is HTML+CSS+JavaScript. Front End specialists usually develop expertise in creating Front End of the web applications using these technologies. Another common skill Front End developers master is slicing Photoshop designs to HTML+CSS+JavaScript web pages.

Back End

Back End developers write code that runs on server. Usually, this part of the job entails communication with the DataBase for reading/writing data, reading/writing files, doing the business logic, etc. In some cases where the business logic resides in client side, then Back End is used to serve the data from the DataBase usually in the form of Web Services. Back End developers usually master one of web programming languages and a DataBase Management System.

 

You can master both, but from my experience, I have seen that all web developers tend to like one more than the other. Some even specialize on only one of them. Although there is a line of separation, there is no limit that which side should do what. Sometimes Front End is used only for visual representation and all the job is done in Back End. In some cases, Back End only serves the data and all the calculations and functions reside in Front End. It is a matter of design and architecture to define which side does what (although, depending on the architecture you choose, there are some guidelines about the responsibilities of each side).

Programming languages

There are a lot of available programming languages for web development. When we want to program on Front End, the defacto standard language is JavaScript. When it comes to Back End, we have plenty of choices. Let me list some of the popular choices:

  • PHP
  • JavaScript
  • Ruby on Rails (used with Ruby programming language)
  • ASP.NET (used with .net programming languages)
  • Java EE
  • Python

And this is not a definitive list, just those that came to my mind right now. So which one to choose. Well, your choice should be evaluated based on some factors like: the job market, hosting environment of the web application, available learning resources, available time to learn, the development community around you.

If you want to work as a web developer, in my opinion the most important factor is the job market. You should analyze the job market you are in (or you want to be in) and chose that language that has most job openings. Another important factor is the hosting environment. For example, PHP hosting is quite cheap compared to Java hosting. If you are going to develop an intranet application which is going to be hosted internally in an organization, perhaps Java EE could be a very good choice, but if you want to host your application online, Java EE could be rather expensive compared to other languages.

With the popularity of Node.js, JavaScript has started to become a popular choice of Back End programmers, however, this is still quite a new and immature technology compared to others, and I would not recommend it as a choice of beginner Web Developer.

In my opinion, PHP has the easiest learning curve, cheap hosting environment, plenty of learning resources and relatively easy development environment, so I would recommend to any beginner web developer start with PHP. ASP.NET is also a good choice. Microsoft offers a lot of learning resources, free development tools and a pretty rich environment. If you like the Microsoft ecosystem, ASP.NET is a very good choice.

Frameworks

If you are a beginner, give yourself some time before you start learning a framework. Frameworks are code libraries which make the life of a web developer easier. Frameworks give a structure to a web application, help web developer do some tasks a lot easier and faster then coding everything yourself. If you want to be a professional Web Developer, then it is a must you learn at least one framework, which boosts your speed of development.

You have a plenty of frameworks which try to be general solutions or specialist solutions. You must evaluate your needs. If you have chosen PHP, I would recommend Laravel as a framework of choice. It is a sound MVC framework which is quite trendy these days. If your choice is with ASP.NET, I would definitely recommend you learn ASP.NET MVC and EntityFramework at least.

Web development can be huge and you may want to focus on one type of applications, let’s say development of web sites with Content Management Systems (CMS). Again if you have chosen PHP, I would recommend you continue with WordPress. WordPress allows you to create web sites, blogs, but also it can be extended with ready plugins or custom themes and plugins to quite complex business applications.

You will find plenty of choices for frameworks for any language you choose, so based on your language of choice, you will have to work with different frameworks.

What next

As a first advice, even if you choose to specialize for Front End or Back End (I would strongly recommend you do), you should have a grasp of the other side, and if you do, your team’s performance will be better. If you have learned a programming language and mastered a framework, what I would recommend is you start with another one. Programming languages have their own philosophies and paradigms, and sometimes some differ quite a lot. Knowing two or more programming languages will allow you have a better picture and understanding how programming problems are tackled and will make you a more fluent developer. As I said earlier, you have to consider many factors when you choose your languages. My choices until today were: JavaScript, PHP, ASP.NET, and Java EE. I’m still looking forward to extend my list 🙂

Do you need to take developer certifications

Software development industry is one of the fastest progressing industries. New technologies, amazingly fast changing businesses, and advancement of requirements make learning a daily task of software developers. In a way, when we choose this profession, we kind of agree to lifelong learning, but there comes the question:

“Do you need to take developer certifications?”.

Personally, I like developer certifications. You can see from my profile, I have taken 9 different industry certifications, mostly for Microsoft technologies. The biggest value I see in taking certifications is learning the details of some technologies. As the saying goes “The devil is hidden in the details”, I like learning some technologies in deep details. I do not claim that I do remember all those details from all the certifications I have gone through, but from the experience, I have had some “aha moments” when some of those details have spared me lots of time. Certifications have also helped me to establish my knowledge and credentials as knowledgeable person in those technologies and help me teach those technologies in various courses.

The effect of certifications on your career

I have read in many articles that certifications help you find a better job. I would not argue that you can look better or more prestigious with all those certifications but personally, I have not seen any case that certifications have been the ultimate factor for hiring someone. Perhaps I’m short of that kind of experience, but I put myself in the shoes of a hiring person, if I’d be choosing someone to hire, the certifications surely would be a benefit or a value added for the candidate, but not an important factor for my decision. The important factor is the knowledge one has, and industry certifications can only be a plus.

The effect of certifications on your professional development

If you have taken and passed an industry certification, most probably you have followed a learning plan to learn all the objectives tested in the exam, and that has pushed you to have some good understanding of that specific technology. Moreover, you have seen the latest developments in that technology and have become familiar with what is required to follow on further developments.

Development technologies advance every day, and if you follow the cutting edge technologies, this is an indications that you are also a productive developer as new technologies most of the time make the development process easier and faster. I have not seen a better illustration of this than this picture

are you too busy to improve

The effect of certifications on your personal brand

Branding is not something exclusive to corporates. We all have our brand, your name is a brand, and you should work to make it better and better. Taking certifications will have a positive impact on establishing a firm expertise in your industry and showing how seriously you take your career and personal development. Certifying your knowledge will have an added value towards the development of your personal brand as an industry expert.

Conclusions

As I stated from the beginning of this post, I am very much into certifications, not from the marketing benefits I get from them, but from the learning and self development benefits I get from the process of preparing to take the exams. Personally, I have had a lot of benefits from the knowledge I have gained during that process, therefore I would recommend taking industry certification exams to anyone who wants to advance in software development career.

Things every programmer should know

Learning process of developers never ends. It is in our DNA to continuously feel the need to learn and self develop. As much as we learn, we have even more to learn. The technology world is moving so fast that to keep the pace and be up to date with cutting edge knowledge, we need to embrace learning as part of our daily activities. Whenever we say we learned to use a framework, we see that 7 other frameworks have become famous and we need to take a look on them. One of the most frequent questions of my students is the question “what should I learn to be a good programmer?”.

Luckily, nowadays, learning resources are so vast, we have difficulties to chose which one to pay attention first. We have plenty of books available (free and paid), free magazines, blogs, video tutorials, MOOC courses, etc. However, cutting the line what one should learn to be a good developer is not an easy task. As doctors have chosen to specialize only on one part of the body, developers too need to decide for a specialization, be it system developer, web developer, business application developer, etc. The specialization is something which comes to question when you reach a steady state of development knowledge and experience, but what do you need to learn to get there. What could be a good developer knowledge path?

Over the time, I have come to conclusion that developers need to know the whole stack of code execution in order to succeed.

What do I mean with this? The computer literacy starts with using the computer and perhaps some basic configuration and application usage knowledge. If you advance in configuration skills, you learn perhaps also about servers, monitoring, user management, etc., you start learning system administration. Then you need to network the computers and servers to work together, and start learning networking, which builds on top of administration skills. Then you feel the need of automation, and that’s where you start with learning programming.

Why do I think this model works? In early times of software development, we used to have only desktop applications which performed certain functions. Today the whole view is different. We rarely develop single computer applications. We either create a web application or have a network aware app. Those applications often may face problems of different nature, especially if they are running inside a corporate infrastructure where proxies, firewalls, and other infrastructure components interfere with the traffic and environment. Most of the time, problems caused by those components will not demonstrate themselves very clearly and often it will look like the application is failing. Finding the root cause of the problem requires good troubleshooting skills and that requires understanding of system administration and networking which are the layers above which your code runs. If you fail to have the understanding of underlying platform, you will be left alone to find what is the problem with your code, as most of the time, system administrators/network administrators will not be able to identify why your application is failing (and perhaps it is not their fault as they do not know the ins and outs of your application), therefore the judgement will be that the code is faulty 🙂

What should you focus to learn? Do you need to be a system administrator and network administrator before you start to learn programming? No, I am not saying that. My suggestion is you get at least the basic understanding of operating systems (perhaps not all of them but those which are in your environment), learn how user management is working, the privileges, and the connection to central user management like Active Directory. Learn how to read system logs, that is the place you will most often find valuable information about what is happening with your code and find the clues about what is going wrong, how to list running processes and see who is consuming the memory and who is consuming the processor. Learn a little bit also about system security,  to setup and configure your production environment and its subtleties and the basics of how the computer networks operate. In the long run, you shall benefit from this knowledge for sure.

I do believe that a “complete developer” is not the one who only knows to write code and nothing else. You should know the whole picture of the environment you develop and the environment your code runs, and this requires you to get a little bit out of your zone and see what you have around. I would like to explicitly clarify one point here. I do not think that developers are above or more valuable than System Administrators or Network Administrators. Everybody in this ecosystem has his/her importance and value. I just want to point out that if you want to know the full stack of execution of your code, you have to have a clue what happens beneath and these are the things every programmer should know. Troubleshooting problems of your applications will most likely come to you as the last line of support, and finding faults in system or network requires basic understanding how those function.

What do you do when your code has cancer?

One truth about business software applications is that they evolve together with business requirements. From different reasons, sometimes from lack of experience of developers and sometimes from not having enough time to devise good solutions, the code often tends to create some sort of cancer inside, which progressively grows to unmanageable pieces of software until it breaks the whole system.

What do we do if we find such phenomenon in your code?

In my experience I have seen that dealing with such code is almost inevitable in brown field projects. Ignoring them makes things only worse. You have to face it and treat it as it is a disease which needs to be cured. Whenever I face such a situation, I follow these steps:

1. Isolate

Changing the code without breaking the whole system, or refactoring as is called in software development terminology, is not an easy task. Every change must be validated and tested well to ensure that changes do not break or alter the current functionality. In order to stop the bad code growing, we need to isolate it first. Isolation could be done by aiming abstraction through loose coupling the part which needs to be isolated. The abstraction is done by creating interfaces for every class that needs to be isolated and make dependent classes call to interfaces instead of real classes. This may require introduction of inversion of control (IoC) / Dependency Injection (DI) container. Each isolated part must be supported by quality unit tests which ensure that the abstraction maintains the code logic which was in place. Unit tests will also help us in the second phase.

2. Repair

This phase is quite simple. When you arrive here you have isolated the bad code and protect the functionality with unit tests. Now you can safely start to refactor and change the bad code. As you change, you should continuously run the unit tests to check if changes have any unexpected effects. If the unit test coverage is OK and they are written well, then you can safely proceed as unit tests will spot if you have broken something unintentionally. I would highly recommend Test Driven Development in this phase.

3. Integrate

Integrating the isolated code is the last phase, and most probably the easiest. Now the bad code should be gone and the functionality is unchanged. Often you shall find this phase unnecessary as the integration has been done during the phase 2. However, sometimes you will find some kind of double abstractions resulting from a lot of refactorings and you will see the opportunity of cutting these unnecessary code.

Conclusions

Perhaps this strategy looks very simple, but in my experience, it has been a very effective one. We are not always lucky to land in green field projects and define good code from the beginning. Besides, it is not always easy to maintain the code in good shape when the team has many developers and there is not a good development process in place.  Sometimes you deliberately allow the code to go in bad direction as a compromise to speed or resources.

The most important skill for Software Architects

I trust anyone reading this post title most probably is expecting to see something like UML Design, OOP Design, writing code, etc. I would not consider these in required skills list, these are I would say, mandatory skills for a Software Architect. In my opinion, the most important skills for Software Architects are the communication skills.

The importance of communication skills

In Microsoft .NET – Architecting Applications for the Enterprise (2nd Edition) book, the role of the software architect is defined as a person who ties together the requirements and specifications, and one of the most important responsibilities of the software architect is mentioned to be the acknowledgment of requirements.

This requires a lot of communication with people of different profiles and various knowledge of technical jargon (project managers, business analysts, potential users, etc.), and it is a natural expectation that Software Architect should speak the language of business rather than the other way around.

Speaking the language of business is one part of the communication. Next comes communicating that business knowledge and requirements to development team. In my experience, I have seen several situations that developers and business people were speaking about the very same solution, but the language terminology they used made everybody think that they are speaking about two different solutions.

It is the technical skills of planning, designing, development, and implementation of a software solution that qualifies one for  the position of Software Architect, but in my opinion it is the soft skill of communication that is the most important skill for software architects and the skill that makes one an appropriate choice to be in that middle point of the team. As my boss says, we must talk talk talk.

What can you do to improve your communication skills?

Of course there is no silver bullet to this problem. We humans tend to be unique in our behavior and skills, and as such the recommendations can not easily be generalized. However, I have three points which I can recommend to anyone:

  1. Seek for sincere advice from people around you, be it your family, your friends, or your colleagues. Generally, it is not easy to get someone to sincerely tell you what they think. People sometimes don’t like to tell what they think and sometimes they are afraid of being percepted as criticizing others, so they don’t tell you exactly how you are being percepted unless they get this freedom from you. Try to make people feel comfortable saying what they think about your communication skills and appreciate sincerely their comments.
  2. Spend some time with yourself thinking about your communication with others. What did you say, what was your intention to communicate and how was it percepted? This could be very helpful to find your weak points, on which you should focus to improve.
  3. Read the book How to win friends and influence people by Dale Carnegie. This is one of the best books I have read and I can confidently recommend this book to anyone. It has an immense set of advices which are very useful for improving one’s communication skills.

You can find plenty of advice from different resources on internet, from books, and from people around you about how to improve your communication skills. Pay attention to the input you get especially from people, you will appreciate it at the end.