Follow by Email

Wednesday, 2 October 2019

Progressive delivery

Coupling is one of the important pattern for building software and it is recommended to build loosely coupled systems. 
Lets talk about loose coupling pattern in software deployment context.

Image result for evolution

Industry has seen evolution in Devops space in form of continuous integration,continuous delivery, automated testing etc but world is moving fast and we need CI/CD++.  Next step after CI/CD is Progressive delivery.

Deploying  != Release
Progressive delivery could sound like cool tech jargon but it simply comes down to drawing line between Deploying in productions vs Activating in production.

This new way of deploying software gives control on how do you want to roll out new features to customers. It gives control on whether to upset all users vs small set of users to get some feedback before whole world knows about it.

A version of progressive delivery is also called Blue-Green deployment, A/B testing , canary testing, feature toggle etc.

Benefit of progressive delivery 
- Low ceremony way of enabling features to user.
- Safe way of testing things in production.
- Less git conflicts to manage because code does not sit in git after it is developed.
- Better operational management because deployment is done in Parts. Your support team will love it.
- Avoid frustration of working on noisy Pre production.  
- Product team are empowered to decided when they want to open it for external users.

Last with not least that Progressive delivery methodology allow team to control blast radius when rolling out new software.

Share your progressive delivery experience. 

If you like the post then you can follow me on twitter.

Sunday, 8 September 2019

Tracer bullet software development

Software development methodology is evolving very fast and every team has found version that works well in current context.

Software development methodology is going through continuous improvement.

The_Pragmatic_Programmer book talks about Trace bullet approach and as per that it comes down to feedback. The more quickly you get feedback, less change is required to hit the target.

I have used Tracer Bullet approach through out my career with good success.

I will share another approach or mindset of software development that can be used in some scenario to build better product and create value.

Explore or Discovery 
Image result for discovery images

Many time as team you have to find what is the next feature you should be building that will help in increasing adoption of product.
So i call this as Explore or Discover phase and this phase of development has very different goal and trade off. This phase means that you have to move fast, cut some corners to get feedback. This phase will not have enough tests, documentation, code quality is not good etc.

Important thing about this phase is you are actively collecting feedback on whether this is the next big idea your team will be investing.
In this phase you have to make sure you gain more than loose, so timebox discovery phase to keep track on resource that is consumed.

Outcome of successful discovery puts you in Growth phase and in many case this will be steep growth, but every unsuccessful outcome has lots of signal on next exploration.

 You Build to learn in this phase and once you learned then move to next phase or start another discovery.

Growth Phase
Image result for growth images

This phase is outcome of successful discovery and now you have found the next feature that market or your target audience need.
Trade off for this phase is very different from Explore phase, you have to stabilized feature , do changes based on feedback so users who have shown interest in idea are still engaged. Users who got on-boarded work like your sponsor, so keep them in loop.

Interesting things about this phase is your team will be in war room type of situation, everyone is trying to get over huddles and get feature out.

Word of caution this phase very intense and demanding. This phase is the real "Sprint" phase not the agile sprint! putting extra hours has good returns.
Another thing to watch out is to be persistent in exploiting maximum of new feature but many time team drops the ball and go back to discovery phase. 

I would say this phase also puts design pressure on team and you can refer to design-pressure-on-engineering-team post that talks about it.

Successful outcome of this phase is Expand phase. Team is exhausted after this phase but very motivated.

Expand Phase
Image result for expand images

Welcome to phase that requires building software in the way we learn in text book, this is the phase where engineering discipline are very important because solution has to be scalable, maintainable , reliable etc.
Now you can go to management and ask for more funds to get servers , expand team etc because this idea will generate some profit.

Don't build product like discovery phase in this stage otherwise you will become victim of your own success, below image should be good example of it.

Image result for victim of your own success

All of these phases has very different constraint and trade off and it is very important to know that, expand phase can't be managed like explore phase or vise versa and i have also found that engineering disciplined are very very different in these phase, so you need team that is aligned with mindset. If you get your team wrong then it can really very challenging to execute phase.

It is fascinating to see that our industry keeps on evolving and new development methodology are found.

It is much more than Agile or scrum.

I want to end with quote
As engineering team we should do continuous exploration and exploration is not linear process.

Some of other post on software development that you might interesting


I will be happy to learn about new ways of building software, so please share it!

If you like the post then you can follow me on twitter.

Saturday, 24 August 2019

frontend vs backend development

I am sure you might have got into discussion of frontend vs backend development or some engineers want to do only one type of development.

Image result for frontend vs backend

I am passionate engineer for more than decade and have got opportunity to see full spectrum.  I have done development on extreme end of both the side.

In this post i will share something on front-end engineering that is hidden and things that is not discussed openly.

Lets start ..

In this part of the work every one understands that it is a world of data structure , algorithm and writing bare metal code, handling scale etc.

In this part of world most of us think is only about building engaging and secure User Interface, but i will say it is just one part of it.
As a frontend developer you are exposed to so many engineering challenges. Lets discuss about it.

Getting started
For any backend related task you can write the quick code or that code can come from Stackoverflow and go and run from IDE.

Frontend getting code is just small part but after that you need some webserver/container to host the code and then know the browser/client that you want to use and then finally code runs.

This is just small example and you can get idea of extra number of steps required to see your code running.

Synchronous vs Asynchronous 
On backend system you have option to choose if code is Sync vs Async but on frontend most of the operations has to be asynchronous otherwise end user experience is very bad.

On frontend you are exposed to this on day one but on backend it will take months or year before you get to state where start thinking about sync vs async .

I am sure if you have done any concurrent programming then you know how hard it is to coordinate async tasks.

Distributed Computing
 Now distributed computing has become so common that now it is hard to think of system that is not making distributed calls.

As a backend developer you are guarded or gets late exposure to distributed computing but on frontend every call to get data is remote call, so you have to aware about failures that can happen when remote call is made and slowness it adds.

Proper error handling becomes optional in backend system but on frotnend it is not the option because user will noticed it and complain about it.

Frontend is the last gate so it has to handle all the errors that are thrown or  suppressed by backend systems, so end user experience is smooth.

You experienced distributed computing very early once you are on frontend side.

We read many text book that "network is not reliable" and as a backend engineer you don't get directly exposed to this because library and framework handles it for you but on frontend you get first hand experience to deal with and come up with strategy

All the backend application gets benefit of fast network ("100 GBs network") because it runs in data center but for frontend application is data center is end user device which will be browser/handheld device.
Many time network is dial up( i.e KBs) and application has to work on slow network.

Compute and In-memory 
This one is interesting because when backend program is slow first option is increase compute or memory because elastic infra allows to do that that but on end user side no elasticity, so first option is no option for front-end friends.

Approach taken to optimize frontend is very creative and innovative as compared to backend. This also put design pressure on front application.

Backend systems has more options on algorithm that can be used to solve program for example Disk based algorithm are very common for many data intensive backend application but on frontend side this option is not available or in very limited way and you have to very creative in how do you use it.

I think many chapters of algo book is Not Applicable for frontend.

On frontend side industry is inventing new patterns every day but backend side does not move at that pace for eg functional composition , incremental rendering , state management using immutable DS , event driven systems, chunking of requests , late arrival of information due to slow network etc

Backend system are never seen from lens on how big jar/exe/dll is but this is first challenge to be solved on front-end side because package must be small so that it can be downloaded quickly by clients.
Network play role in this remember 100GBs vs Kbs ?

This can be little controversial but in many case frontend are built with fuzzy or no requirement and later requirement is added. Requirement is must for backend! 

This is the hardest part for frontend. I will leave this for now because it needs multi series blog just for this topic.


I know it might look like i am just trying to sell frontend development is more complex but my point is you become better engineer when you move to frontend.
If you are not doing any frontend then find way to do that or learn about these hard problem from frontend engineers and incase they say "i don't think about these challenges" then educate & help them.

If you like the post then you can follow me on twitter .

Saturday, 17 August 2019

JVM with no garbage collection

JVM community keeps on adding new GC and recently new one was added and it is called Epsilon and is very special one. Epsilon only allocates memory but will not reclaim any memory.

Image result for garbage collection

It might look like what is use of GC that does not perform any garbage collection. This type of Garbage Collector has special use and we will look into some.

Where this shinny GC can be used ?
Performance Testing

If you are developing solution that has tight latency requirement and limited memory budget then this GC can be used to test limit of program.

Memory Pressure Testing
Want to know extract transient memory requirement by your application. I find this useful if you are building some pure In-Memory solution.

Bench marking Algorithm.
Many time we want to test the real performance of new cool algorithm based on our understanding of BIG (O) notion but garbage collector adds noise during testing.

Low Garbage
Many times we do some optimization in algorithm to reduce garbage produced and GC like epsilon helps in scientific verification of optimization.

How to enable epsilon GC

JVM engineers have taken special care that this GC should not enabled by default in production , so to use this GC we have to use below JVM options

-XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xlog:gc

One question that might be coming in your mind what happens when memory is exhausted ? JVM will stop with OutofMemory Error.

Lets look at some code to test GC

How to know if epsilon is used in JVM process?

Java has good management API that allows to query current GC being used, this can also be used to verify what is the default GC in different version of java.

Run above code with below options
-XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC VerifyCurrentGC

How does code behave when memory is exhausted. 

I will use below code to show how new GC works.

Running above code with default GC and requesting 5GB allocation causes no issue (java -Xlog:gc -Dmb=5024 MemoryAllocator) and it produces below output

[0.016s][info][gc] Using G1
[0.041s][info][gc] Periodic GC disabled
Start allocation of 5024 MBs
[0.197s][info][gc] GC(0) Pause Young (Concurrent Start) (G1 Humongous Allocation) 116M->0M(254M) 3.286ms
[0.197s][info][gc] GC(1) Concurrent Cycle
[0.203s][info][gc] GC(1) Pause Remark 20M->20M(70M) 4.387ms
[0.203s][info][gc] GC(1) Pause Cleanup 22M->22M(70M) 0.043ms
[1.600s][info][gc] GC(397) Concurrent Cycle 6.612ms
[1.601s][info][gc] GC(398) Pause Young (Concurrent Start) (G1 Humongous Allocation) 52M->0M(117M) 1.073ms
[1.601s][info][gc] GC(399) Concurrent Cycle
I was Alive after allocation
[1.606s][info][gc] GC(399) Pause Remark 35M->35M(117M) 0.382ms

[1.607s][info][gc] GC(399) Pause Cleanup 35M->35M(117M) 0.093ms
[1.607s][info][gc] GC(399) Concurrent Cycle 6.062ms

Lets add some memory limit ( java -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xlog:gc -Xmx1g -Dmb=5024 MemoryAllocator)

[0.011s][info][gc] Resizeable heap; starting at 253M, max: 1024M, step: 128M
[0.011s][info][gc] Using TLAB allocation; max: 4096K
[0.011s][info][gc] Elastic TLABs enabled; elasticity: 1.10x
[0.011s][info][gc] Elastic TLABs decay enabled; decay time: 1000ms
[0.011s][info][gc] Using Epsilon
Start allocation of 5024 MBs
[0.147s][info][gc] Heap: 1024M reserved, 253M (24.77%) committed, 52640K (5.02%) used
[0.171s][info][gc] Heap: 1024M reserved, 253M (24.77%) committed, 103M (10.10%) used
[0.579s][info][gc] Heap: 1024M reserved, 1021M (99.77%) committed, 935M (91.35%) used
[0.605s][info][gc] Heap: 1024M reserved, 1021M (99.77%) committed, 987M (96.43%) used

Terminating due to java.lang.OutOfMemoryError: Java heap space

This particular run caused OOM error and is good confirmation that after 1GB this program will crashed.

Same behavior is true multi thread program also, refer to for sample.

Unit Tests are available to test features of this special GC.

I think Epsilon will find more use case and adoption in future and this is definitely a good step to increase reach of JVM.

All the code samples are available Github repo

If you like the post then you can follow me on twitter .

Wednesday, 14 August 2019

Need driven software development using Mocks

Excellent paper on mocking framework by jmock author. This paper was written in 2004 that is 18 years ago but has many tips of building maintainable software system.

Related image

In this post i will highlight key ideas from this paper but suggest you to read the paper to get big ideas behind mocking and programming practice.

 Mock objects are extension of test driven development.

Mock objects can be useful when we start thinking about writing test first as this allows to mock parts that is still not developed. Think like better way of building prototype system.

Mock object are less interesting as a technique for isolating tests from third-party libraries.

This is common misconception about mock and i have seen/written many codes using mock like this. This was really eye opening fact that comes from author of mocking framework.

Writing test is design activity

This is so much true but as engineer we take shortcut many time to throw away best part of writing test. Design that is driven from test also gives insights about real problem and it lead to invention because developer has to think hard about problem  and avoid over engineering

Coupling and cohesion 

As we start wiring test it gives good idea on coupling & cohesion decision we make. Good software will have low coupling and high cohesion. This also lead to functional decomposition of task.
Another benefit of well design system is that it does not have Law_of_Demeter, this is one of the common problem that gets introduced in system unknowingly. Lots of micro services suffer from this anti pattern.

Need driven development
As mocking requires explicit code/setup, so it comes from need/demand of test case. You don't code based on forecast that some feature will required after 6 months, so this allows to focus on need of customer. All the interfaces that is produce as result of test is narrow and fit for purpose. This type of development is also called top down development.

Quote from paper
We find that Need-Driven Development helps us stay focused on the requirements in hand and to develop coherent objects.

Programming by composition

Test first approach allows you to think about Composability of components, every thing is passed as constructor arguments or as method parameter.
Once system is build using such design principal it is very easy to test/replace part of system.
Mock objects allows to think about Composability so that some parts of system are mocked.

Mock test becomes too complicated
One observation in paper talks about complexity of Mock Test.
If system design is weak then mocking will be hard and complicated. It does amplification of problems like coupling, separation of concern.  I think this is best use of mock objects to get feedback on design and use it like motivator to make system better.

Don't add behavior to mock
As per paper we should never add behavior to stub and in case if you get the temptation to do that then it is sign of misplaced responsibility.

If you like the post then you can follow me on twitter to be notified about random stuff that i write.

Thursday, 25 July 2019

Exception handling

In this post i will share how error handling is done and what options we have.Error handling is complex topic :-)

Image result for error handling

I will add some context from wikipedia on what is exception handling before going down the rabbit hole of exception handling
Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional conditions requiring special processing – often disrupting the normal flow of program execution. It is provided by specialized programming language constructs, computer hardware mechanisms like interrupts or operating system IPC facilities like signals.
In general, an exception breaks the normal flow of execution and executes a pre-registered exception handler. The details of how this is done depends on whether it is a hardware or software exception and how the software exception is implemented. Some exceptions, especially hardware ones, may be handled so gracefully that execution can resume where it was interrupted.
Source - 

Few things that is highlighted are "disrupting the normal flow of program execution" , "pre-registered exception handler" , hardware or software exception.
So it explain what error handling is , so i will not spend time on that.

One interesting thing mention is 2 types are exception exists( hardware & software), hardware friends have handled very gracefully and it on software engineer to do part.

Software one are the hard and too many programming languages makes it even harder.
I want you refer to simple-testing-can-prevent-most post on which i try to explain the side effect of wrong error handing and it pure as the result of exception handling pattern.

C way
I am sure if you seen this and have thought that "is this the right way ?".
Code snippet of C error handling

This approach has several issue 
 -  You have to check for error after calling every function that can fail. 
 -  No safety from compiler on forcing/indicating that error can be thrown at this point
 - Error handling is completely optional

Java Way

Then came java and came with mindset let me fix all the error handling and they invented checked/unchecked exception.
Look at code snippet

This approach has every more issues
- Code is full with verbosity of error handling code
- Compiler forces you to handle checked exception in wrong way(i.e just log it or ignore it)
- Nothing meaningful is done apart from log something and wrap it in RuntimeExcetion to get passed compiler.
- Wrapping makes things worse because you start loosing context on what caused error

Functional Programming Way
This world has to do better than "imperative" world and what they did ?  Invented Monads.

Things to consider when using this approach
- You have to learn fancy technical jargon of Category theory or monads
- Now gives 2 value and you have to write little less verbose code to handle both the path
- Performance issues due to extra wrapping of value and when you have millions of them then it hits you very hard
- No compile time safety , caller have an option to get around this by directly getting the value
- and i think this was attempt to fix Optional/MayBe value, in which you don't know why value is not available.
- Stacktrace is gone and in some case it is useful especially building system that is calling third party libs 

Go Lang Way
GoLang wanted to do better than C/Java and took some inspiration from Elm language and came up with delegation or Killer(i.e Panic) approach

This is interesting approach but 
-  With err return in very function call , caller has to add error handling code
- Trace is lost, so you have to very careful in adding all the context to message so that recovery is possible.
- Panic is not good for library or framework because you can't kill the process , it has to be client responsibility to decided on what to do.

JavaScript/Python way
I will leave this for now.

No clear winner in which option is best and each language is doing some trade-off.We don't exceptions like java ans also like Go Lang, it is 2 end of the pendulum.

What could be good is having caller option to decided on what approach to use it could be Java Style or Go Lang.
Better way to separating control flow and error because in some case default value on error could be good option or just cleanup/recovery or send to upper layer to better handing.

So code in catch block tell lot about what client want and that should decided what error handling pattern you should use. I think it is more about education on what is right in context and use the pattern.

Happy to know about what you think about error handling and how it should done.

Sunday, 28 April 2019

Cargo Cult - Innovation Center

Cargo Cult is serious problem in Software industry. I think Innovation center is example of cargo cult.
In this post i will share my views on innovation center.

Cartoon: man carrying ideas sees that door to Innovation Centre is closed.
Innovative Idea killer

People think Innovation center is cool place to work but many thing or almost every thing done at innovation center fails.

Why innovation center is open ?

It is hard to innovate at current place because of process , ceremony, approval & permission etc, so what company/team do is "Lets open Innovation labs" or "Innovation initiative, rather than fixing real problem that are causing friction this new innovation thing is started to feel better.
Teams are changing the way they behave not how they think.

This labs are nothing more than expensive press release stunts and it adds no value.

No alignment with product road map
It does not align with product road map or big mission and it runs on parallel/side track that is not going to meet to main track.

It is new, interesting , shiny but never scales and finally team does tell "How do we launch this ?"

Thinking of "New" . It has to new thing , new brand , new experience  , new tech stack etc. This new thing will never fit in old (i.e product roadmap), so no one wants it.

Working for wrong customer
Work for board of director or executive that sings the cheque for these labs. Team starts working for wrong customer (i.e executive or press) and ignore the real customer.

Unfulfilled dream
You get all the creative people for these labs and very soon they have unfulfilled dream that nothing gets used by real customer. Team gets frustrated and burn out.
It becomes mental gymnastics that goes no where and to make it worse learning/failures are not passed to real delivery team that will make it production ready.

Too much of freedom
Balance is missing in innovation labs and they always run on exploration/experiment mode and does not get close to exploiting the learning.
Too much process makes you slave and no process/structure makes free fall. Finding right balance is important.

Image result for balance innovation 

No credibility 
Very soon innovation team loose all the credibility and people ask question like
 - Why are they doing this ?
 - What are they producing ?
 - Why they don't come and talk to tech teams ?
innovation team moral is crushed .

Idea development is not inclusive

Any product that is successful in market needs 3 things it should be feasible, desirable & profitable.
Feasible is where tech team comes in and confirms that it is feasible to build the product.
Desirable is design team that confirms whether any one want it or not.
Profitable is product team looking from financial/brand gain.

In most of the ideas driven by innovation team all 3 groups are not partner and in case if they are then one of them is dominating due to which needle is not moved in right direction.

Change innovation as spectacle to innovation as strategy to build better products. 
Keep innovating :-)