17 November, 2018

Try,Catch and Exception

In this post I'd like to share my personal preference of handling exceptions.




I'll be frank I don't like to handle exceptions at all. I always prefer to prevent exceptions rather than handling them. It's not possible to write the perfect software but we can certainly try and  thrive for that. For example if you are making a calculator you are expecting numeric values. Instead of handling non numeric values it's better to ensure that users can't input unwanted values. So in stead of handling exceptions we prevent it from happening.

It's not possible to prevent arithmetical errors. Such as dividing something by zero or executing an operation that has no mathematical definition. I still haven't figured out a way to prevent these let me know if you have.

While I'm in developing something I always avoid writing Try Catch Blocks. The main reason I do that is I don't trust my own code. Because I'm human and humans can make mistakes. Whenever an application throws an exception it's certainly something to be fixed today/tomorrow/100 years later. If I hide my exceptions behind a try catch block I'll most likely never notice the exception. So when ever my application crashes I get happy instead of getting upset. Because Now I know exactly where my code can be better. And also I gain a new knowledge about the exception that occurred.

So what knowledge did I gain so far? 
  1. Whenever my application throws an null pointer exception I instantly understand that I didn't initialize a certain variable or I need to make sure the code doesn't execute to next step for null
  2. Whenever I find an out of bound exception I carefully check the boundary condition of an array that I was iterating over.(I figured later that it's better to use ForEach loop instead of worrying about indexes)
  3. Whenever I my application crashes and says, "File Not found" I realize I wrote some stupid code where I didn't check if the file existed or not.

You might say "I can still find these exceptions if I put code in try catch block". Well yes, Certainly you can. BUT you will find the bug sooner this way. Since your application will keep crashing until you fix it. And it will save a lot of time. There has been a lot of time that while developing a feature of a software we find a bug and fail to pinpoint the reason of it. Most often it occurs because of an exception somewhere. Maybe you are iterating over a list of data that comes from database but in the Database module there was an connection exception and there was no data. You will keep wondering why there was null in the list but until you debug step by step you can't find exactly where the exception had occurred. But if you didn't handle the code with try catch,as soon as there was an exception you would know since the application would crash there. Exception handling is for exceptional cases. If your application doesn't run without Try Catch , You are probably using Try catch for unexceptional cases.  Just because you can, Doesn't mean you should. It's always better to have your application crash a lot than deliver faulty outputs. An exception always changes your program flow. You can't trust your own code after one exception has occurred.

When do I use Try catch?

I almost never use try catch during development phase. Only for EXCEPTIONAL cases I might consider. One such Exceptional cases would be math errors that's certainly an exception. If I were to define Exceptional cases I'd say, If there is no possible work around for it, It's Exceptional. No API call's certainly aren't exceptional. One way or the other API's will return you something a status code? or a null data or something. Manage with those. File Exceptions ? Not found? Don't have permission? Fix those. Don't be lazy. Maybe 0.1% of the times you will find a faulty library function or Faulty OS feature Only then if you are 100% sure it's a 3rd party bug that you can't work around with, Go for a Try catch.

All that being said. Don't forget to add try catch back before you plan to ship your software. You certainly won't want your application crashing on your client's face. But in alpha/beta releases try to avoid Try catch so that you can deliver a better software when you go live.


10 November, 2018

Lazy Programmer


I would like to introduce myself as a lazy programmer.

I don't like to type a few lines and remove those again again until it works.

- Yeah I prefer to write codes only when I'm sure that's what I want to write. For this I do one of two things. I write down my thoughts on a piece of paper or something similar. Or I just think about in my head. Once I'm sure that this is what I want only then I write the code. Before writing a single class I think what's its purpose or what dependencies will it have or what other classes might be dependent on it. Or Is this class even necessary ? What properties the class should have. Why is this property even necessary ? Do I want others to know about this property ? No? then make it private . Does this property need to be modified? No? make it read only. Same goes for functions. If I think any function that doesn't require external access I'd make those private. How this helps you might ask? Since I'm lazy I don't wanna remember how this class works. I make the class name obvious. Make sure the public functions/property names are self explanatory. So that I can totally forget how this class works. When I need I just create an instance and see what functions it offers.


Function and Property names.

- Since I'm lazy I don't wanna come back and rename the A() function or BB_ variable or property that I wrote down in a hurry later. Because Coding in a hurry would just add more work time later. Because If I ever have to come back to the code(Which I always have to) I'll be at a loss. Because the names of the function or property will make no sense at all. So To save later work I'd rather write down the names properly now which might cost me 1 extra second now that will save 1 minute later.


Reusable Functions

-Every time I write a function I ask myself what possible usages it can have. Because right now my function my just do one task but it might need to do bit more later. Suppose I'm writing a function that inserts a data into a file.Lets call it WriteToFile(). Now I ask myself should it be a void function or it should return a boolean of it's success. It'd be easier to just write a void method and just be done with it. But then it hit my mind that since it's a write to a file operation it could throw some exceptions like not being able to open or write file due to access restrictions. But my function here wouldn't know that.It's just going to throw an exception. Which I'll have to find later and tear my hair. So instead of solving that later let's fix it now. I'll make this a boolean function and put a try catch block if any exception occurs I'd return false otherwise the file has been written successfully so I can return true. If I want to go one step further I'd also put an out parameter(C#) to the function to send the exception as well. So how does it help? I can use that WriteToFile() Like before but now I have one more option available to me. I can check if the function has successfully written the file or not. And show the users appropriate messages. I couldn't do that before if I had a void function. In case there was an exception the application would just crash. From my experience It's always good to avoid void functions. If you are writing a void function you are just  going to add more work later.


Stick to one convention

-I always stick to one convention. I'm not talking about naming conventions only. I'm talking about everything we do in a code. For example I always write properties at the top of the class. If the class has way too many properties I group them into sections and comment them out so the groups stand out . Why? This helps me find those later. Since I'm lazy I don't wanna waste my time scrolling up and down. After I have written down all the properties I go on defining the methods. I make sure the methods are grouped together as well so that similar methods are near one another and In case I ever need to go through it, it should be near my hand.

Being lazy at coding doesn't mean not writing code. It means Write your code properly and efficiently so that you don't have to waste your time over old codes.



A STITCH IN TIME SAVES NINE

26 October, 2018

Singleton Design Pattern

Before you start

It's expected that the reader is already familiar with the term design pattern. Knows how to write a code in at least one Object Oriented Language(C#,Java etc). Understanding of  Encapsulation. Constructor, Static Keyword.

What to expect

In this post I'll be talking about.
  • What is a Singleton
  • Why do we need it
  • How to make one
  • Refactoring

Singleton

What is a Singleton?

- Singleton is a design pattern that ensures that there is only one Instance of a class throughout the whole application.

Why Singleton?

- You might be wondering why do we need a class that we are only going to instantiate only once? Classes are made so that we can create objects of it. That is true but while writing clean codes you might want to follow some convention and follow some rules to write code. For example if you were to write a code for querying a database. You would want to make a manager class for handling connection. Lets call it ConnectionManager. If you think logically, You don't need to create more than one connection to database. So in this case you would like to have only one ConnectionManager Object. Now here you may ask, I can remember this. I'll not create 2 instances. I'll tell my team as well. That is certainly a solution. But will you remember that 5 years later? Or If your team grows can you tell everyone to keep track of singleton's manually? A design pattern is not a Rule. It's a Convention. If you follow a convention , it will enforce you and your team to write better code. It will ensure that you do not write bad codes by mistake. If you follow the singleton pattern, even you can't make another instance by mistake. So even if you forgot, The Singleton will remind you not to write bad code.

Lets make one

I'll be using C# to show how to make a singleton. But the logic behind it would be same for any other language.


First we Make a Class named ConnectionManager. And give it a constructor.

1:    public class ConnectionManager  
2:    {  
3:      public ConnectionManager()  
4:      {  
5:        //Some initialization  
6:      }  
7:    }  


Here's the 1st problem. Our Constructor is public so you can always Create an object with
new ConnectionManager();

So we would like to prevent anyone from calling the constructor from outside. We need to make it private.

1:    public class ConnectionManager  
2:    {  
3:      private ConnectionManager()  
4:      {  
5:        //Some initialization  
6:      }  
7:    }  

Now nobody can access the constructor from outside of the class. Now we are found with a new problem. So how do we get an instance of the object? We do want ONE instance. But the only way to create an instance we must need to call the constructor. WHICH by the way we just made private. So there is no way we can get an instance. For this we will take the help of static reference and keep one reference inside of the class.

1:    public class ConnectionManager  
2:    {  
3:      public static ConnectionManager Instance = new ConnectionManager();  
4:      private ConnectionManager()  
5:      {  
6:        //Some initialization  
7:      }  
8:    }  

Now we can get the instance of the class without accessing the constructor directly. Like this
ConnectionManager.Instance;

This is still far from what we would like to have. Because every time we GET the instance it just creates a new instance and gives us that. We don't want that. What we want is , If the instance does not have a reference of the object then we would want  to get a new instance else we would like to get the existing instance. So What we would like to do is write a function that does exactly that. We need to add logic. And also lets make that Instance variable private so nobody can access it directly either.

1:   public class ConnectionManager  
2:    {  
3:      private static ConnectionManager Instance;  
4:      private ConnectionManager()  
5:      {  
6:        //Some initialization  
7:      }  
8:      public static ConnectionManager GetInstance()  
9:      {  
10:        if (Instance==null)  
11:        {  
12:          Instance=new ConnectionManager();  
13:        }  
14:        return Instance;  
15:      }  
16:    }  

Now if we call Connectionmanager.GetInstance();
We will get exactly what we wanted. Yeah that's all there is to it. You got yourself a singleton class. Whenever you call GetInstance it will give you the only existing object reference on the application.

BUT WAIT

We can refactor the code. Lets start with refactoring the function. We are going to use ?? operator to change the function in one line.

1:   public static ConnectionManager GetInstance()  
2:      {  
3:        return Instance ?? (Instance = new ConnectionManager());  
4:      }  

I would leave this ?? operator for readers to do research. But I'll explain the code. Now you see, We always want the function to return An instance. so we are always returning the Instance variable. What we need to check is if the instance is null, We need to assign a new instance and return that. That's what I did in one line.

It can be even better

In C# we have something called properties that act like a variable but can be written logic inside of it like a function.So we can remove the function entirely and make the class look something as simple as this.

1:    public class ConnectionManager  
2:    {  
3:      private static ConnectionManager _singleton;  
4:      public static ConnectionManager Instance => _singleton ?? (_singleton = new ConnectionManager());  
5:      private ConnectionManager()  
6:      {  
7:        //Some initialization  
8:      }  
9:    }  

Now not only the code is more clean but also you can use the Instance like a variable instead of a function. Like this Connectionmanager.Instance;
But remember that this property is a C# feature. if you are writing a JAVA code you would need a function to get the instance.

Every public function inside of the singleton class can be accessed via that instance. Now you can't even create two Database connecting by mistake and save yourself from destroying your query system.


30 September, 2018

Why our games fail? (2)

You probably have an idea about a game. lets assume that you made it. It's not the best but it's a good one. Fun to play. Maybe it's going to hit the hearts of a few thousands if not millions. That's great actually. So what's the problem. Now you start to think about monetizing the game. Of course you would want to monetize your game. Lets talk about monetization first. The most usual way to sell your art/product is to pack it and sell it for a price. Or there's a new way of selling products. Selling products for free and putting unnecessary leaflets inside your product and forcing your customers to watch /remove those to consume your product. Yes I'm talking about ADs here. Suppose you bought a tooth paste, lets put ads in tooth paste. How smartly can we do it? Lets share some ideas.
  • Put ads on the tube so that everyone has to watch the ad while they hold the tube.
  • Lock the cap and force customers to watch an ad before they can open it.
  • Put ad on the paste so customers can see the ad when they brush.
Okay instead of monetizing , Lets use a monetized Toothpaste. Mmm, Now you see how annoying it is. You would rather pay for a premium paste than that free with ads. At this point you were no longer selling services. Instead of thinking about quality, You planned about how to put ads in your product. 

So what's wrong with our games. lets make a monetized Super Mario.
  • Every time you get an 1UP you need to watch a 30 Sec Ad else it will not be credited.
  • You need to unlock Powerups to be available in game. Which requires you seeing more ads everyday or purchase it via micro transaction.
  • Mario Talks about new upcoming random games every 10 second. 
  • Watch ads to play as Bowsette. 
It's not really fun to play anymore is it? What we are focusing on is implementing ads to increase our revenue instead of focusing on the story and game play. At some point developers started asking money for updates. They are calling it DLC. It's like a Burger but the Bun,Mayonese,Toppings.Meat are sold separately.

 Before I'm a game developer. I'm a gamer. There has been tons of cases I stopped playing games because it's no longer a game. It's just grinding. Most android games now are like trying to pull you back to the game by giving you rewards. But to be honest one should play the game because he wants to not because of some reward. If your game needs rewards to retain players, It's a failure as a game. Ad monetization is what ruined our game industry. Now games are designed in a way so that player has to keep the phone on so that ANDROID can show more ads to earn and give the developer some too. Daily Rewards/ Daily Quests AH COME ON! Games were supposed to be played for fun. Can we just go back to the old model? Pay once and it's yours to keep. No more free games. Come up with demos. 1-3 hours free demo? or a part of the story demo. Take a closer look at the recent years of game development. Larger Companies are falling off. Getting Back-lashed. Where indie developers are sticking to the old ideas.Updates are being releases for free(Although they too call it DLC).   I don't hold any grudge against android . But here are the facts. Android just isn't good for games in it's current state. Games Demand Physical controls not virtual buttons on the touch screen.
Remember old JAVA phones when we actually had physical keypad. And it was fun to play games on it too. Those were actually games that gamers would actually play. Endless games.. ahh how is that even a thing? Everything good comes to an end. You get my point?


If you have any opinions  on the matter do let me know in the comments section.

23 August, 2018

Graduation, CGPA and It's Usage

This is more like a Timeline than a blog post. I will be updating this post from time to time to show a timeline of the usage of CGPA or my BSc in Software Engineering Certificate.



  • 2017 March: I got my first JOB in iQuantile as a Game Developer. Guess what They didn't ask for my CGPA.
  • 2018 January: I was promoted to  a manager.
  • 2018 February: I Graduated from AIUB. I was awarded Summa Cum Laude for achieving a CGPA of  3.98 out of 4.00 .

  • 2018 March : Showed off my gold medal to everyone until l i got bored and gave my mother to store it to god knows where.

  • 2018 August : Started to maintain this timeline. It's almost a year but I don't even know where did I store it, Let alone use it. By this year the only time my Certificate was mentioned was for a very specific reason. Some random relatives asked my parents where do I study or stuffs like that. My parents said,"He's done BSc in Software Engineering from AIUB". I was hoping that they'd mention the CGPA at some point but when I looked at their face I could clearly read, THEY HAVE NO FUCKING CLUE WHAT'S A SOFTWARE ENGINEER IS! They were like "Good,Good."  I hope by the time I die I can at least mention once or twice on how I needed this Certificate. 

  • 2018 December: Appointed as a Jr. Software developer at Brain Station-23. Well they asked me why am I not doing masters with this CGPA. Probably worried if I'd leave for my masters while at my job. Hmmmm...


16 August, 2018

Why our games fail?

It's been almost 3 years since Bangladesh is trying to launch a proper game on the international market. And we have not yet been successful so far. I would like to share my observation and findings.
Let's talk about what makes a game great. Before I'm a game developer I'm a gamer. I used to play 18 hours a day. I've finished over 500+ titles (probably) across multiple game platforms. So I can tell you a thing or two that makes a great game.

I believe there are 2 key ingredients for a great game.
  • Game play
  • Story

And there are a few extra ingredients that adds flavour to the game.
  • Graphics
  • Audio
  • Control

A great game will have all of these in proper ratio.One thing we must remember, A game is more like an artwork. There are one or more ARTIST behind it. I'll come back to this point later on. Let's get back to the main topic. Let's start with examples.

One of 2016's best game was Witcher 3. Successor of Skyrim. What was it that earned these games Game of the year Awards? Well both of them had something in common. Mind-blowing open world . It wasn't randomly generated like No man's sky. It's 2018 and there are still place's in Skyrim people discovering.
Witcher 3's story line is something that everyone just yearned for. Game play of both games were mind-blowing.
But these are AAA title examples. Let's give a recent indie game example.

Hollow knight by team cherry 🍒.This game is mostly known for its game play. And simplistic design and it's music. But I myself would say the story of the game was not very clear. But still the game was super hit.
To make a good game you don't need to have both of the key ingredient. One is good enough, but you must work on extra ingredients for covering the short comings. Story and game play alone can make a game super hit. It doesn't need to have super cool 3D graphics.

For example we have Undertale.
It looks like a game from 1990's. But the story just makes you to play more.

Remember NFS 2? It didn't have a story but we all loved the game. Why? Game play.








I've given examples of games that have Both Game play and Story or just one of these and some supplementary attributes.

So what was it that we were doing wrong? If you take a closer look at our root of game development, you can see the problem. Most of our game developers don't actually want to make a game. They want to make a game that will be viral. That will earn lots of lots of money. lots of lots of fame. Now here's where we make the greatest mistake. We have already drifted away from game development to product development. Now in case of a product it has a target client base. It requires ample market research. It requires client feedback. etc etc. you get my point. As I had mentioned previously A game is a form of art. Now imagine an artist went up to a canvas started drawing whatever on his mind. And another artist went up on a canvas and started drawing a logo that some company ordered. Guess who's art will need revision? The 2nd one. revision for an art is a bad thing. Because the artist wanted it to be something and the client made it into something else. It was no longer something the artist wanted to do rather had to. You can't force an art. In result what he delivers is an product. A product dies after a few uses but ART persist through the ages. Do you think Leonardo Da Vinci cared about what you think about Mona Lisa ? Or did he make it so that he will be paid? He made it because his heart felt like it. Greatest art works were never made for money. So why is it the games are customer oriented ?


When ever I share a game Idea with someone the 1st constraint the put on me saying that, "Can it be played on Android ?" why android because it has a very good ad revenue market. We will talk about it later. But see what did he do? He halted my idea with a constraint . Now tell me , Can I let my imagination flow freely once I added the constraint android ? So I already drifted away from what I was initially planning to make. Most of the times it will make the game shittier. Lets face it. Androids have less control capabilities as close as to nothing. All you can do is swipe and tap. Lets not argue about virtual controls .. ohh please I want to see how fun it is to play Multiplayer games on touch screen versus someone on PC with proper controls.


Another fact about our country developers that, they are totally hungover making a game on our liberation war. Brother do you really want to make that game or need the fame? Well either way everyone failed. If your game is something that people play for a day and throw it away and never talk about it, it's a failure as a game. As a product it may have succeeded if you actually hit some download count mark or revenue mark. But as a game it's an utter failure.

If you really want a game that produces money. Then forget about money first. Make a good game that you want to play. If it's a good game and you are willing to pay for your own game, People will pay for it too. Ask yourself if your game is worth paying for, Would you pay for it? if yes it's gonna make a hit don't worry about it. Focus on what your game should be.

When planning about a game we must come out of the thoughts of marketing first. That's what we usually do. And that's why EVERY SINGLE GAME we made has failed . Because it wasn't an art. It was a product that people tested out for a week  and threw away.

What we need to to do is think about a GAME with STORY or GAMEPLAY or both without worrying about the platform or the target audience or anything at all. If the game is good everyone will PAY! if the game sucks nobody will pay. So it doesn't matter which target audience we aim for or which platform in the end The baseline is it has to be a good game.

Here's another mistake I would like to focus on. I see a lot of people talking about game ideas like. Hey.... this game is doing good. Lets make another one like this . For example 2018's Hit game was PLAYERS UNKNOWN BATTLE GROUND.
And by the end of 2018 we have around 50+ same genre game. And most of those sucks bad. it's like trying to sell a clone Monalisa with some modifications. Why this trend is common? We all want easy fame. Life isn't easy. You have to work hard for it.



I would like to remind you of a game you probably never hard of, It's one of the oldest battle royal games even before PUBG. It was called THE CULLING.
It failed hard. Why did it fail hard? This game was doing really great at it's early stage. But the developers made a great mistake. They were continuously changing the game by listening to almost every player feedback. So how did it break the game? Well As I have mentioned before if you do revision on Art it's bad. The Culling became something different. Something the developers didn't plan for. It was no longer an art rather it became a combination of art pieces from different artists. Too much cook spoil the broth. It's not a good idea to change your game according to what people say. It's your game you should stick with your ideas.

Your game doesn't need to have super cool graphics. It doesn't need to have super cool animations.
what it needs to have is your soul. Your sweat . Your pain. Your love . Your anger. Your Imagination.Your Dreams. And that is how you make a great game .

If you make something good, Money will follow. Don't worry about it. For once try to make something that you want to play not what people might like to play. Thanks for reading this long post. if you have other thoughts please leave a comment bellow.









04 July, 2018

A Roll-back Story




A Roll-back Story is a platformer genre game. It's heavily influenced by recent game titles of 2017-2018 such as Hollow-Knight , Ori And the blind forest , The end is neigh.



In this game you have to take control of a ball and guide it through traps and enemies to reach the end of level. Each level has a gate locked and there's a switch/key that opens the gate.





Simple as it may look like the game actually requires you to have precise control of the ball. One wrong press of the button will ensure your demise. Like every other game you do come back from the death .




But if you die too much you are in for a surprise that you might not have expected.






In the full release of the game there's supposed to be a narrator to guide you through the game. He might sound friendly but he's not. And he's a part of the game so pay attention.

The story starts simply like every other fantasy game. Two nations doing their things . And suddenly one nation attacks another and everything is burning. And our wild hero appears out of no where with literally no backstory.

As you progress the the level the game will go through dramatic changes. Such as design of the levels might become more and more colorful.
Sneak peek
I don't want to spoil the story but the change of design is a part of the story. So bear with it.


The demo of the game is currently available on steam. And the team is trying to crowdfund the game through kickstarer. If you think the game has potential do back us.

The platforms that we plan to release the game on is currently Windows,Mac,Linux,PS4,XBOX.




Here's a my personal play through of the demo.


Do leave a comment. What do you think about the game?


06 June, 2018

Software, deployment and product key

If you are a indie developer. Specially if you are still a desktop application developer. You might have come to this very point when deploying your product. Yes you always wanted to put a CD key or product key with that application. But you are smart enough to know that keeping a list of verified keys on the desktop application would be stupid. And for whatever reason it is you can't afford a server. And there's hardly any easy to use service to maintain the used key list. Well here's something that I did when deploying my super secret application that I never talk about. Email server. Yeah you heard me right. So I opened a new email account for free for the application. I put a pop3 or smtp server on the application. Now if you are smart you already figured out what I did next. But sure I'll tell you. Since it's a desktop application. I setup my new email account on the application. So whenever the user inputs the product key for verification all I do is download all the mails from my new account and check for subjects that matches the product key :p . If I find match I delete the mail and activate the product. Whenever I need to create a new product key I send a mail to that account with the product key as subject. Surely you can put more security in this system by checking email sender and putting content on body. This method is secure as long as nobody knows what email is embedded in the system. It's also cheap as you don't have to maintain an API server or something. You can do this for games as well or Android apps.

28 May, 2018

Project , Design And I


Design of a project structure will start mattering when you are working on a huge project with multiple peoples. It’s very easy to get lost on where what is written. This is why Design Patterns came to be. One of the most popular and most flexible design pattern of a project is n-tier architecture. I’ll be talking about this design pattern on this post.

I’ll call the Whole project as solution. No, I’m not talking about C# projects only. Declaring this because otherwise this term project will confuse readers in multiple places.

N-Tier Architecture: 
It basically divides the whole solution into multiple tiers. Each tier will work with one type of concern. N stands for your tier numbers. For instance, your project can be 3-Tier,4-Tier etc. It can also be 1-Tier as well. For small solution it’s very common to follow a 1-tier Architecture since there are very little concerns to think about. Another thing to be clarified, one solution Should have only one executable. If it has multiple executables it should be divided into multiple layers instead of multiple tiers. We will talk about multi layered project another time but for now just know that each layer is one standalone executable.

How many tiers should one Solution have?
Well that’s a very good question but there is no definite answer. It’s all about personal preference. The more experience you have the more tiers you can define before starting the solution. From my experience each solution usually creates multiple tiers that I never needed before. But I could always suggest a few templates.

But First let’s talk a bit about layers, Always breakdown executables into layers. The current pattern that the world follows for designing any database related application is that it always has an API layer. A Database layers. And obviously multiple Front-End Layers. Bear with me if you got lost already. Well Front-End Layer is basically the UI Solution that Only Requests Data from the server and shows it to the clients. Almost Zero Logic related tasks are performed here. A Standard Solution should follow this rule. But you know… It’s hard to follow the rule everywhere. The API Layer, is where all the calculations happen. Well you could burden the database with complex queries to do most of the calculation for you. But As far as I know it’s best to bring data from the database layer and do the calculations on this layer. And ofc Database Layer, which most of us usually ignore. But Did you know you can Code on Database as well. Which is called PLSQL. A well-designed project should implement PL-SQL on database and define triggers and some more things on the Database Side. Now each layer is divided into multiple tiers.


API Layer Breakdown:

Let’s start with API layer breakdown. Well there’s no definite number that must be followed. Your solution might need less tiers or more. But most commonly there are 3 tiers.

Application:

This tier is the entry point of the layer. All the API configurations such as routing, white-listing are done here.

Business Logic:

This tier is basically the Core of the project. The application layer only accepts request and returns some message(Data). The business logic tier is the part where you define what should be returned and in what format etc.

Repository:

This tier is where you communicate with database. Business logic layer communicates with Repository to get data from database. Here’s the part where you write down Queries of Database. NO, I mean no Queries should be written outside of this part.
Now There are some Tiers that I Strongly recommend making. But first I forgot to mention about Model/Converter Projects. These are easily Mistaken as Tiers but I don’t want to call them as Tiers. Because their sole task is to make other tiers communicate with each other.

Special Type of projects:


Data Model:

This model represents the database. This model will be used to communicate with database.

View Model:

This is usually made optional. But I strongly recommend making one View model project. In most cases the view model and data model are same. But that’s not always true. You might want to show data from multiple tables on a single view. What’s a View you ask? View is basically what the clients See. It can be an HTML Page.

Converter:

If you make a view model project you will need another project that converts view models into data models and vice versa. Initially you will feel like this is just a hassle but trust me this will make the Solution much more readable.

Why Do I recommend the view model and converter along with Data model On API Layer?
Because Usually front-end developers are a different team. They need not to be burdened with database’s design. It’s easier for them to communicate with the API layer with a View model. It’s not just easier it’s also faster. Because then front-end developers won’t have to create a Conversion project with a different View model. Because that’s what they would end up doing. So, it’s best practice to design the logical parts on the API layer not on Front-End Application layer. One way or another these 2 Projects are added to the solution. Better do it on the API layer.

More Breakdown: You can breakdown the layer into more tiers. For example, you could even make Business logic into 2 different project that suits your need.

Database Layer: I’m no database architect so I can hardly tell anyone what to do. But as much as my knowledge serves It has a few configuration stuffs. PL SQL part and Triggers. These should be taken care of.

Front-End Layer: Front end layer could get complex depending on Technology. And platform. But there are some basics that can be commonly described.

Controller:

 Controller is what handles the request. This is the head of Front End. This will communicate with API/Backend layer and bring RAW data. Then format it with Model.

Model:

This model is the View Model. It’s best not to design additional set of Data models because API/Backend layer wasn’t optimized for View Model. But in most cases, you won’t get a perfect view model. So, you will probably need another data model project with converter.


View:

This project will only contain views that the client sees. No logic should be written here other than those that construct the view with Models
Now know that this is not some absolute rule. Rather a starting point. Each project is unique. Most of the time you will need to configure these layers and tiers as your project suits. Instead of memorizing the pattern feel the pattern and understand it.



17 May, 2018

Better, Worse and Us

I've never been a good student , that's why I always felt when I was at school and college. My parents, relatives made me feel that way. When I got into University it's not like I got smarter. That's not how any of this works. You see since the day we are born we start comparing our lives with others. We measure our achievement with respect to what others achieve. Our parent's want us to be doctors or engineer because that saw those title makes them feel more achieved . If our Poets/Artists was earning as much as Doctors or Engineers they'd be trying to make us Poets or Artist instead of Engineers/Doctors.

So why is it that I/My Parents/ Others thought I wasn't a good student ? Well you know there's always someone better than you. Unluckily I was matched with people that were far better than me in the school. Yes they were great. And they got admitted into Public Universities with other great students around the country. Now when I look at them, I can see the same old me in them. They had met people better than them. Now they feel like oh, I'm so stupid but that guy/girl is very intelligent. But from my perspective they were the one of the most intelligent ones. Now here's the thing when I got into university I saw people treating me like I used to treat my intelligent friends . Then I realized everything is relative . There's always someone better than you and also someone worse than you. And none of it actually matters for the very same reason. Because there's no such thing as good/bad student.

We just have this delusion of being better no, Best. you can never be the best. The more you thrive for it the more you will realize it's pointless. Instead find peace with what you have and hone your skills. Be confident about it. There is only one thing that you can be best. And that is being you. Only you can be the best you. Since the day one we were told we can't be Einstein, Newton . We don't really have to be them. I wish my parents wanted me to be the first me.


13 May, 2018

CV, shortlist and others




I'd like to share how do we shortlist CV. But first Know that this is how I or the people I know does shortlisting. So I could miss a lot of points. But I'll try to point out most of the things I know.


We never check your CGPA , instead what we check is if you are a graduate or still a student. Now graduates get more priority. But first let's talk about students. There are two types of student that apply. 

One that is confused about life. Just want to get a job desperately another one is passionate one. If you are a confused student we can figure it out pretty easily. For example confused students will apply for digital marketing and feature programming skills on CV. If you are a programmer why are you applying for digital marketing? If you are interested in digital marketing why are you showcasing programming?

But the same thing could be reversed in another case. If an EEE student applies for development with a few good maybe just one good project we expect him/her to be passionate one. He's probably going to be shortlisted.

The CV should contain relevant data to make reviewers interested in to you. Experience section is thoroughly checked. But beware. If you have 3-4 Job experience in a year... Then you are less likely to be shortlisted. Because we think that you have a tendency to switch job as Soon as the opportunity arrives. Company expects stability. But of course if you have 3-4 years experience from one place you will have a higher demand. Experienced people are more likely to be shortlisted.

There's another factor that's called luck. It's unprofessional but it does matter. Sometimes how you represent yourself could offend the reviewer or amuse him . Better not do something unprofessional in the CV. Well I did do something like that. In my CV Wrote that I need a valid job to get married . Well my boss was cool enough to let that slide. But your reviewer might not be. To be honest I did that to ensure that he's actually cool with my attitude. Because you can't just go shift jobs just because your boss didn't like something you said or vice versa. Don't take a job without knowing if your compatible with each other just because of the pay scale else you will regret it.



05 May, 2018

Programming, Language and I

One question that I always face, "Java or C#? " . Sometimes the language name changes but the choice remains. Since we were young, we were taught to always compare two or more things. As a result we can't stop comparing 2 things. Firstly I'd say the question itself is stupid. So the answer is also a stupid one. In the end the answer of this particular question is but an opinion. Why are you trying to decide which language you should learn based on someone else's opinion? If you are smart you will try to avoid answering to stupid question like those. Let's modify the question a bit. Why Java? And Why C# ? Now that's a question that is worth answering. Java has some feature that C# doesn't have and C# has feature that Java don't have. 


C# 

Pros:

If you are a windows fan boy. C# is what you should choose. Don't even look at Java. C# actually has quite a few wonderful features that Java won't provide. Properties. Java don't have properties. You will love properties once you get fed up with Java's redundant getter and setters. To be honest this is the only feature that is good enough for me to switch from Java to C#. Another good reason is Solution. I totally love how they manage projects with solution. In Java you have to do this with package. But C# made it beautiful by adding a visual root project that is called Solution. I don't recall java having a package manager where as like most other popular languages C# has a built in package manager called nuget which you will come to love as a developer.

Cons:

The biggest drawback of C# is , It's actually built for windows application focused. So if you are planning to make a cross platform application you will be at potential risk. C# is a programming language true. But it's dependent on .net technology for development. And that's dependent on windows. There's a Cross platform version of .net that is known as Mono but that's left for another day. If you plan to deploy a cross platform application with C# you will find it a little bit difficult to do so directly. Even if you see that you can develop Android and iOS applications on Native C# you should not do that. Trust me.


Java

Pros:

Old tech. Rich libraries. Cross Platform. Same code will work on Linux , Windows and Mac. If you are planning to distribute your application on multiple platforms with lest amount of pain. This is a very suitable choice. I don't recall any extra feature that Java offers but C# doesn't other than this.

Cons:

It's Slow. SLOOOOOW. Everything good has it's draw back. Also you won't find it's binary built in on windows or most other OS distributions. You will have to Ship the JRE with your application most of the time which kind of makes the product heavier and looks stupid.

A personal test info: I made a windows form it took 5 MB ram to run it. I made the same thing on Java. Which looked far more aesthetic and easier because there were libraries for new design. But it took 80MB ram to run the application. So if you are aiming for a memory efficient application .. Java won't be a very good choice. But if you wish to have a good looking app that runs on Windows,MacOS and Linux ... Then Java is a suitable choice given that memory is not an issue.


Python

Pros:

FAR Richer libraries than C# and Java. Cross Platform . FAST! It's faster than both C# and Java and I mean like 3-4x Faster. No need to worry about that semicolon. No need to think about braces. Best for most cases. No need to declare data types. It's Magical. Probably the best development option right now.

Cons:

If you don't maintain indent , this is not for you.If you love data types this is not for you. If you need braces like i do , This is not for you. Python isn't your traditional programming language. It's python.
If you wish to develop large scale web app this won't be reliable. If you wish to develop desktop application you can use PyQt which has some licencing issues. If you want to publicly distribute your application you rather not use this.


C++

Pros:

Father of C# and Python. Faster than Python. Cross platform.

Cons:

You will have to manage the memory.Developing applications are not as easy as other three above.This is for very hard core developers that want to have access to the memory. For example game developers loves C++ as they can talk directly with the machine with this. If you wish to develop desktop applications. You have a good looking library Qt. You can get a free version of it.  But the Development process is tedious.


C

Pros:

Father of every other language. Fastest High level language.

Cons:

It's stupid to develop applications with raw C. It's also not Object Oriented.

Now it's here's the thing.  All of these are used for developing applications of different tiers of developers. its for you to choose which language suites your need best. Don't let someone else's opinion influence your l

02 May, 2018

University, Cgpa and I

One question that I always see, freshers ask,"Can I get a good job with my *.** Cg pa?". There's a short answer and a long answer. If you want the longer and detailed version do ignore the short one.


Short-version:

I'll give myself and my experience as an example. I was a student of American International University Bangladesh. I completed my bachelor's degree with 3.98 Cg pa. I was awarded the maximum honor. Sum ma cum laud. Since I'm from CS background I will only talk about the job market of CS.
So does CG PA matter for getting a job?
98% times the answer is no. So you can stop reading any further.
So what's in the 2%?
Teacher and Researcher. If these two don't pique your interest then you can forget about cg pa. Going abroad is included in research field.

Long Version:

This part will be a bit detailed for what I made such a blunt statement above.
I've given and taken enough interviews to let you know which part is actually checked in the CV for shortlisting. Actually let me tell you the parts that are ignored first hand. Your educational backgroundyour grades. Shocking isn't it? No. Nobody cares where are you from as long as you know things that will benefit the company. One of the core feature could be your skills. Another can be your ideas. How does a company get a glimpse of your skills? Or ideas that you have. Well for ideas it's simple. You need to start blogging to let others know that you know stuff. For skills you need to provide at least one good fully working project. And it should be hosted on some public git community, such as Git Hub.
First thing we do is check the Git Hub profile. If you have weekly contributions all over the years, it is a good profile. I saw people only publishing the project once done and never updating it. Most of the case I would think that this code could be stolen or something. Then we open up a random code file and check out if code has been done following some convention. Did the project follow a design pattern. Well design patterns are bonus marks where as convention is critical. If you didn't name your variables properly or line indent is not cared for. There's 100% chance that your CV is not looked at any further. Just in case everything goes well. We check your educational background. If the cg pa is high, you will probably not get a call. Because company needs stability. It's quite common with high cg pa students to go abroad. This is probably a  worst case scenario. There's a chance that's why I mentioned it. So those with very high cg pa... You have something to worry about.
Now have you once noticed that I checked the cg pa to decide if I should shortlist him/her? No? Exactly my point.
CS related task doesn't require you to have a degree. It only cares for what you can do for the company.  So focus on building skills.

Things that matter in a CV? Maybe another time.Stay tuned.....





26 April, 2018

Project, Mistakes and I

I was assigned as a team leader for an office project . There were two developers under my command.
To make the project successful I took various steps . Some of those steps didn't prove to be effective.
I'm going to point out some key mistakes of mine.

  •  Held the wheel most of the time 

I thought it would be wise to navigate the ship myself while teaching my team how to do likewise. Maybe it would have worked in some cases. But in my case it didn't work out as well as I had expected. On the contrary it backfired. My Crew never got the practical knowledge . When I let them take the wheel, they were at a loss in the middle of a sea. They were over whelmed. Even though I did follow a pattern in the project. Even though they did write 80% of the code. They got lost as soon as I left them to code alone. Well the best way to learn is by making mistakes. Everything I learnt was from my mistakes. I took that away from them and hence I took away their learning mechanism.

  • Easy way out

Funny you may think. It does sound stupid. If I don't share my knowledge with my team, what's the point of being the leader? Here's the catch. I learned that solution from facing a problem and thinking about it. I had learned more than the specific problem when I was researching. But when I gave away the specific solution. I actually stopped their thinking process. They might have come up with a better idea. But since the problem was solved, their brains lost interest about thinking about better solution as any human being would.They didn't learn how to google for the problem. As a result when new problems came up. They were looking for my assistance instead of Google's.

  • LEGO Design

One of my most favorite ways to develop a software is to break it down to small modules as such as LEGO blocks. So that I can just plug it in into any future project. I'm a lazy programmer. I don't want to write the same code twice.
When I assigned task for my team members I only gave them small objectives with small outcomes. I asked them to build LEGO bricks for me. They did. But they couldn't see the bigger picture I had in my mind since I didn't exactly share what was I going to do once I have the bricks ready. Although my plan was to make them use their own bricks and build a castle. They were at a loss when I asked them to build the castle . They went back to thinking about how to build bricks. Which they had already done with out knowing. At some point they did realized that the work was done long before. But Since I never explained the actual purpose of the bricks , They were unable to join them all together. Just because I knew what the small bricks can be used for , that doesn't mean my team will actually be able to think that far.



Best way to learn is to learn from mistakes. Even a team leader makes mistakes. We are but human.