I need Bower ? or Grunt?

I need Bower ? or Grunt?

When we start learning MEAN stack, we get this question for sure. Even I asked the same question when I initially heard about these two tools. I thought they both does the same thing. To discuss this, First we need to know what these two tools does.

When we started developing every layer in Javascript, we need some tools to make our life easy. The most common one’s you need are, the dependency management and build management.

So, I would like to start with what they are…. then you would see the differences easily.

Assumption: Before you read further, I assume you already know how to use npm command and install packages like Grunt, Bower. (If no, try this link)

Let’s get started with

Bower

Why Bower ?

  • Acts as a Package Manager
  • Dependency Management of the modules
  • Bower works by fetching, installing packages and keeps them up to date.
  • Bower downloads the dependencies for you and installs them on the required path.
  • This installation could be as global module or project module.

Key Features

  • Bower runs on Git
  • Can be integrated with other tools like Grunt, Gulp etc.
  • Bower can manage any packages hosted on NPM platform
  • Can manage HTML,CSS, JS packages

In my view, whoever comes from Java,J2EE background can easily relate this to a Maven and its POM.XML to the bower.json file. In this file, you exactly give the same content what we give in Pom, the dependent libraries and their versions. This is very useful in later phases if you want to change the version of any library you are using just go hear and change the version. You are done. Even you can manually download the js file and keep it. To avoid this manual work and make developer’s life easy we need this tool.

Grunt

Why Grunt ?

  • Grunt is a Task Runner
  • Grunt is a task based command line build tool
  • Helps to automate any step while building you application
  • Can be integrated with many plug-ins
  • Very commonly used for jobs like Minification of CSS, JS & run Unit test cases

Key Features

  • Grunt helps you run tasks based on configurations
  • Provides automation for different environments like Dev, Test, etc
  • Helps you to increase the performance of the application using different plugins
  • Helps you optimize images, minify file sizes, run unit tests

In my view, Grunt acts like our good old Apache Ant, where you used to define the tasks in BUILD.XML and run them  based on the need. Very similarly Grunt helps you create your own tasks and run them based on the your requirement. Here we define Gruntfile.js where you define your tasks.

I think now, you got a better understanding of these two tools.

Now these two tools are meant for two different things. So, don’t get confused. We need both of these tools. Where as there are tools which are very similar to Grunt for eg. Gulp. We need more detailed comparison if we have to choose one of them.

Happy Reading ūüôā

Advertisements
Angular JS – How to create a Controller ?

Angular JS – How to create a Controller ?

Here I am going to show you the ways you can create a controller in Angular JS.

I am assuming, you already know the advantages of Angular JS and how to use Angular JS basics like ng-app, ng-controller, $scope.

Just to give you some basic idea on Angular JS, It is a Web Framework which would give you lot of flexibility and de-couple your Model-View-Controller with the client side code. This has been the most popular and critical feature of Angular. Lets try to get into the controller part. The controller is very important component in the MV* pattern which Angular talks about.

This controller can be created in 3 different ways which I would show you here.

Basic Way: (Controller as Global Function)  / app.js

This way is easy to create, perhaps this is not the best way to solve the problem. As this is a global function there could be many complications when we have multiple functions defined in the app. If the app grows bigger there is no way to isolate this function from others. So, this is not the way to go.


var app = angular.module("app", []);
var TestController = function($scope){
 $scope.count = 10;
});


2nd Way (Application level Controller)

This is application level controller defined as we are defining controller on app. Tomorrow we might need many other things at application level which might be included in the same controller. So, this is the angular way of doing it, still not the best practice. There could be modular way of doing it and adding as dependency to the application (app).


var app = angular.module("app", []);
app.controller('TestController', function($scope){
 $scope.count = 10;
});

3rd Way (Module level Controller)

Here we are defining another module which is a controllers and added this module as dependency to the app module. This way tomorrow if we want to add another controller we can simple add it to this module and it will be available in the application easily. If we don’t want the new controller exposed to the app then we can simply define another module. So, here is the best practice to create a controller in Angular.


var app = angular.module("app", ['controllers']);
angular.module("controllers", []).controller('TestController', function($scope){
 $scope.count = 10;
});

Note: To keep the simplicity, I have used a very basic example to show you the differences. You can use the same HTML given below to test all the three controllers. Put the controller code in app.js file.

HTML :


<!DOCTYPE html>
<html ng-app="app">
<head>
 <title>Hello</title>
</head>
<body>

<div ng-controller="TestController"> 
 {{count}}
</div>


</body>
<script type="text/javascript" src="js/angular-min.js"></script>
<script type="text/javascript" src="app.js"></script>
</html>

Thinking in OO way

Thinking in OO way

Most of the times when we get new developers in Java World, as senior developers and Architects we advice them to think in OO way. What does it mean? We may take some example within the project or in general like Vehicle as ”¬†Object¬†” and list down the properties or attributes of any vehicle and list down the nationalities which are common for all vehicles to define the interfaces.

Then we will straight away move to inheritance, encapsulations, abstraction concepts. But if we take a step back and think why these names are given for these things in Java by learning their real meaning of these words, we might explain things in Java in a different way. And for the learners also it would be much easier to relate Java to reality.

Object Oriented Programming (OOP), If I understand the philosophy behind¬†Object¬†correctly, “A material thing that can be seen and touched.” Are our Java Objects can be touched or seen ? That is not the reality, so our Objects are the simulations of real world objects. That’s the reason why Java is Object Oriented (OO) language. In any real project we take the real objects and try to simulate their properties and behaviors in Java, this is called as OOP.

Then we should understand the other terminology of Object orientation. I will try to cover very important one’s here.

Inheritance,¬†This looks like a biological term if you are not a programmer. It may even look like Law term if you are a lawyer ūüôā , The real meaning of it looks like this – “The process by which traits or characteristics pass from parents to offspring through the genes.” ¬†In our OO context it applies to the classes and their behaviors. It is exactly the same as what we do get from our parents as inheritance.

Encapsulation¬†, This is a general English term used to wrap something in another, The dictionary meaning says – ”¬†to¬†enclose¬†or¬†be¬†enclosed¬†in¬†or¬†as¬†if¬†in¬†a¬†capsule“. It is very easy to apply the same idea to the object. We would like to encapsulate the data inside the object – thinking How?¬†using simple concept of Bean, Using private attributes for class and use getter and setter methods wherever required to access the data in these private attributes. This is how we secure/ wrap / capsule ¬†our data using encapsulation.

Abstraction, This word means – ”¬†Existing in thought or as an idea but not having a physical or concrete existence¬†“. So, Its easy for us to understand when we have the idea on the functionality, but we are not sure what exactly it means. How we can achieve this in Java ? – Using Abstract Class / Interface. We will define interface when we know the common functionality which is abstract ¬†at this point and can be implemented in any way you want in future.

So, this way we should first understand the real meaning of any concept we would like to understand and try to relate the things to the classes, Objects, methods, attributes etc.

Wish you happy reading ūüôā

Best example of OO thinking – ¬†This image courtesy –¬†devcv.me

OO thinking
OO thinking
Best Qualities of a Software developer

Best Qualities of a Software developer

developer working

General description of any developer role would expect required skill set, mostly the companies expect java/.net/c/c++.

Most companies even expect the developers to know good language skills and analytically strong. But do we think that should be sufficient for any developer?

Most of us might agree, because we expect developers to code nothing more than that. What are the other skills you might expect from a developer, I might suggest you would be a very good developer if you posses these qualities.

  • Never Give up Attitude
  • Patience
  • Innovation
  • Team player

If I am the hiring manager along with the skills developer posses I would try to probe on these areas. Let me elaborate on why I am thinking these are the key things for developers.

Never Give up Attitude:

Development or writing programs are not as easy as you see from outside.  Even a very simple problem like saving data from brownever give upser to Database  might create some expected errors when you are try. Some errors  /exceptions you get might look silly when you see from outside, but when  you sleeve up and make your hands dirty then only you will realize the  actual problem. As I developed code for more than 10 years I am aware of  the issues developer might get into. So you need to try try and try until  you succeed. I particularly see this attitude in the candidates I interview.

How you will find out “Never” give up attitude?

You should ask a question / program to developer which is almost ¬†impossible to solve in the given time.¬†A very simple way could be give a ¬†small project instead of asking a simple prime number program and ask ¬†him the class diagram and code with in 15 mins. Which he will not be able ¬†to achieve. Then after 15 mins you ask him to show whatever he/she has ¬†done. Developer will immediately say I am not done yet, and he already realized that it is going to take more than 1 hr to finish. If you ask him/ her would you like to attempt it if I give you 5-10 mins? Now you will understand the attitude of the developer. If he/she gives up and say no, even after 10 mins I won’t be able to finish they are not ready for attempt itself. I might not take this developer for my team.

Patience:

patience This is a very important attribute of a developer, I myself didn’t understand why some code is not working at many instances. So, you need to be very patient when you do programming. This is not the only reason why you need patience. The first and important reason you need patience is to listen and understand the requirements of business. Any software’s aim/ objective is to solve the business problem, If you don’t understand that completely and create a solution for it, it might not solve the problem but it might increase the problem for user.

Every time you write code you have to wait sometime to see your code working. If it is a server side coding then you should have to wait for some time to build the application and wait until it gets deployed to server, then test it and find that your code is not working then you have to redo these steps again ūüė¶ Nowadays there are lot of tools like Maven / Eclipse who made our development process very easy but still you have to repeat these steps as a developers many times as part of your Job.

If you don’t have the patience to repeat these steps, you might not be a fit for this role ūüė¶

How to test patience of the developer?

This is a very interesting question, but it is a very difficult question as well. This is something you can’t figure out in a very short time like interview of 30 mins to 60 mins time. But sometimes you should be able to guess based on the expressions of the developer when you try to ask the same question in many different ways to him / her. Or If you have a better approach please comment on it.

Innovation

InnovationThis is an attribute every developer should have intrinsic innovation. I could see nowadays the organizations are very much forcing the developers to come up with innovations, I am not sure how it will work in reality.

Motivating developers to innovate is a good thing. Where as I have seen many ideas not even considered when they reach upper level. I am not saying this is wrong, they might not see the value of this innovation as they have a bigger picture in mind. Sometimes they have to comeback to developers and explain why their ideas are considered to make them understand that bigger picture they have. Other wise this might lead to demotivate developers.

How to identify Innovation ?

Again in a small span it is very difficult to understand and assess this ability of developers. I usually ask developers what is the “NEW” thing you have done in last 3 months apart from doing regular coding. It could be learning new framework, tool or API from development. Some times I get completely different answers like started learning Guitar, French etc. So here there is no right or wrong answer. But this would give you some idea what he /she is doing New in their life, this is a very important thing because developers should be learning new things every day then only they can do some innovative thing.

Team Play

team playerLone development is a past, considering the distributed teams globally I think nobody in today’s world would develop a software alone. Yes I agree with you on, sometimes you might have to go to a quite room and do your coding alone. Team play is usually encouraged for developers as they can learn from each other when they work as a team. And understand each other as individuals also very important to work as team. If you see the business perspective of teams is – if any one person’s unavailability should not stop the show.

How to identify a good team player?

This is a tricky one to address in interview, I tried asking questions like If you get stuck in a problem what will you do? Some developers say I will go to senior developer and ask. This might sound like a team player but he/ she should do a though-rough investigation of the problem and find the root cause of it and still if they could not get the solution from searching all possible online sources then you should approach senior developer. Then you might ask about what you don’t expect from your team members. For this also I got some very different answers from developers for eg, unfriendly, non supportive etc. you might have to probe them to get to what exactly you want to hear as these are very vague answers.

Conclusion:

When you hire a developer you might even think of many more things than these four but I feel these are the most important along with the technical abilities of any developer.

Gamified Software Development

Gamified Software Development

In the recent past I have been learning about “Gamification“. I started thinking if I can think of a development process instead of the regular way how it would be? I mean the Gamified one.

The basic idea of Gamification is focus on the intrinsic and extrinsic motivations of developers. How to find out the intrinsic motivations of developers ? This is the key challenge

Firstly developer should be interested to code ? How to motivate them ? The code quality should go up ?

The usual way the companies deal with is if the developer codes and there is a Bug figured out by Tester/ QA developer will loss his/her motivation, because somebody else is pointing out the mistake he/she has done.

I have seen many times there is a clash between Developer and Tester. The primary reason for this could be “Ego” (accept it or not), this is the reality.

So, to fix this issue and Gamify the process we might say If each developer find a bug in his own code it would be suicidal.

Sharing could be a good motivation – Share what you have done today ? Example – “Fixed 2 P1 bugs today” could be an achievement and developer might get 10 likes for this from distributed teams.

So, developer might like to share and get more likes he/she might try to do more work than expected. If the issue re-opens then QA should comment on I re opened this bug as comment and he/she might get more likes than developer, which motivates developers to test properly before they say it is fixed. This could be an insult to developer and may de-motivate also sometimes.

Getting access / control could be another good motivation:

  • Create a group/forum related to technology or tool you use.
  • Ask all developers to participate and share the knowledge they have.
  • If they get to solve more than 3/5/10 questions asked in the forum would have a special badge (Gold Level, Platinum Level) , Based on Level, the developer get access to more privileged content or may become moderator of that group.
  • This could be pride for a developer and he might learn lot of things to answer the questions of other developers too.

Any other ideas to improve quality of software we produce and Gamify the process would be great ūüôā

References:

Gamifying development process by Infosys team

Software Architects & Designers

Software Architects & Designers

Some days back when I was discussing something with my friend over a coffee we had this question. His idea goes like this – “All developers when they become seniors, they do design the system. If any developer with good ¬†designing experience of some years, can become Architect.” I agree the fact, that you need a designing experience to become an Architect, however all designers may not be good fit for an Architect.

I would try to give my own definition of these two roles,¬†let’s try to be on same page, then we can move on with the discussion point Architect Vs Designer.

Architect :¬†He/ She is the one who defines the high level abstraction of the system/ software. The system/software may contain many different components inside. If it has many components then Architect’s job is to define the integration points, choose right technologies to different components, choose right tools & methodologies for these defined components. In some cases Architect even can influence the development process like introducing new step/ stage for code review and test with code static analysis tool before checking the code in to repository. He/ She is responsible for non-functional requirements like Scalable, Maintainable, Flexible, Available system.

Software Designer is not a very regular designation in software companies. So I would consider a Sr Developer / Technical Lead who is designing software for some years.

Designer : He / She define the low-level of the abstraction,each component should be designed by Designer to meet the functional requirements of that component by not compromising on Performance and Scalability of the system. Designing detailed interfaces and implementation of them.

I would like to map the things in a tabular format, for easier understanding.

Architect Designer
Vision Strategic (Long term – Alignment to Business) Tactical (Short term – Integration between modules /components)
Abstraction High Level Low level
Defines Skeleton of the System Fill the Skeleton with Designing the details
High level components Design each Component
Involved When ? ¬†“What” Phase of the system “How” Phase of the system
Focus Area ? Non Functional requirements (Scalability,Availability,Flexibility etc) Focus – Functional requirements
Suggest Frameworks, Methodologies, Integrations, Tools, Technologies, Patterns etc Best Practices, Applying Design Patterns, Design Considerations
Create Component Diagram, Interaction overview, Deployment, Use case, Class, Package(optional) Class, Package, Object, Activity, Sequence
Document Architecture Overview, Integrations, Design Decisions Design Decisions, Best Practices, How to ..s ?, CODE

Finally a pictorial view

Architect_Vs_Designer

I hope this is useful for the people who are trying to understand these roles. Thanks

Useful references :

Software Architecture defined by Carnegie Mellon University

Learn UML Diagrams and their Importance

StackOverflow Architecture Vs Design Discussion