Software Engineering experiments

My thoughts about Software Engineering

Loosely Coupled: The Missing Piece for writing efficient code – Part I

The trick to write less error prone, well maintainable and indeed better code – reduce ‘Coupling’ between objects in your code. These technique is well known as “Law of Demeter

[Prerequisite: Object-Oriented thinking, Basic Java]


In this part we will define a simple real world problem and in the next part I will post my thoughts to solve the problem:


Lets start by considering a trivial example of a ‘Paperboy’, who needs to get payment from his ‘Customer’ at end of the month.

Lets define some code for a Customer,which customer has to offer:

public class Customer {
private String firstName;
private String lastName;
private Wallet myWallet= new Wallet();
public String getFirstName(){
return firstName;
public String getLastName(){
return lastName;
public Wallet getWallet(){
return myWallet;

Now let us consider a simple wallet class which customer is holding in his pocket:

public class Wallet {

private float value=7;

public float getTotalMoney() {
return value;
public void subtractMoney(float debit)
value -= debit;

Simple as it is!

Let us now have our paperboy have class have access to them by:

public class PaperBoy {

private final static float myPay= 2; // “I want my two dollars!”

public static void main(String args[]){
// code from some method inside the Paperboy class...
Customer myCustomer = new Customer();
Wallet theWallet = myCustomer.getWallet();

if (theWallet.getTotalMoney() > myPay) {
System.out.println("You got it");
} else {
System.out.println("come back later it"); // come back later and get my money

Well, well everything is quite setup when you compile above snippet it run flawlessly satisfying our customer.

But, wait ….There is a serious design flaw in the above code!!

Why Is This Bad and what is the problem?

If you look again at the paperboy class, you may well notice that Paperboy is having access to the wallet!!

Oh, boy.. Let us put this as: when the paperboy stops by and demands payment, the customer is just going to turn around, let the paperboy take the wallet out of his back pocket, and take out two bucks.

In real world no one would ever, never do that.

So the problem clearly is:  Paperboy class, it is dependent on the Customer class and the Wallet class. These three classes are now ‘tightly coupled’.  If you change something in the wallet class, corresponding customer class and the paperboy class needs to modified.

Bottom-line is: If we change the Wallet class, we may have to make changes to both of the other classes.

The missing piece is to break the tight coupling and write source code which needs to be Loosely Coupled

In the next part, I will continue to ponder my thoughts and read through what would be the best solution to solve this problem.

Further reading:

Add your thoughts in comments and try out the above snippet in your favorite IDE. Although, the problem is trivial and well studied in OOP. However, sometime we overlook on our core fundamentals and design our solution wrongly.

Hope this post alerts you — to not design your code with tight coupling!

Stay tuned!!

Break dependency within unittests– shuffle them ya’

One of the amazing functionality to embrace Google test framework in writing unit tests and Integration tests for C++ is– it’ offers us a “rich set of features”. Yes, indeed brillant. Why? it makes our life easier!

This post is clearly a praise to use simple flag “–gtest shuffle”

For the basics of the google test and how to get started is well documented on:

Let us describe a simple scenario how this feature will help us to save our day:

Primary goal  to write unittests for our source code is to achieve dependency and test it’s functionality in all use cases. As simple as for the developers, to motivate and write unittests all along..

But, wait! what happens if there is a dependency inside our unittests!!!

Oh well, we may not have expected that, but there is a great possibility for that. So, now our mind may wander how to solve the dependency between our tests?

Without introspection, the solution is to use “–gtests_shuffle” flag!

By using -gtests_shuffle we harness the potential of randomizing our test execution order rather than executing them sequentially. This simple feature helps to reveal bad dependencies between all our tests.

The main trick how google test framework builds the –gtest_shuffle is by simply using random seed calculated from the current time stamp. No magic!  (Refer:

Henceforth, statistically our tests are run like a pseudo-random generator breaking or revealing all dependency between our tests.

So, bottom-line is: we wrote unittests at first place with no dependency between test cases. A double sided benefit :)

Simple and a powerful feature “–gtests_shuffle”

Now your turn, go ahead and write your unittests without  any dependency and improve your code quality of the software.

Can we write a Container Independent code at all?

Recently, I have been reading about the Effective STL by Scott Meyers and must read book if we want to write a good re-usable code still following best practices. This article reviews Item-2 chapter of the effective STL book.

Pre-requisite: Basic understanding of STL, Type definitions, Classes in C++

Track: Advanced C++, Design principles.

Idea of Generalization:

We know the whole concept of object oriented programming is to write a piece of code which encapsulates all low level features under the hood. For instance, simple functions can be generalized as algorithms and Arrays can be generalized into containers and so on. However, can we write a code to generalize container and hide them implicitly.

Short answer: For the former it’s difficult(useless) but for the later it is possible.

Code to Generalize container: 

Just highlighting the differences between the sequence and associative container draws the below table:

Sequence Container (vector, deque, list) Associative Container (map, set)
•Push_front, push_back •No support
•No support •Time complexity: logarthimic for using




The above table clearly draws the line between the sequence and associative containers…

So, How about we then Generalize within only Sequence containers?

Answer is Nope!

Because,  lot vary between within sequence containers.

Such as List supports only Bi-directional iterators leaving out all usage of algorithms using Random access iterators.

So, finally can we wrap up and restrict only for the Associative containers- Sorry, still no!

Since, a rational to generalize sets and maps is nearly impossible as one uses single object and other uses the multiple object.


So, it is very clear that our wish to generalize the container is impossible. But, how can we still write good software hiding or generalizing a container apart from the code.

Answer is use Encapsulation, encapsulation, encapsulation and encapsulation!(Ok that’s too much of emphasis)


Let us say we have class:

Class Widget{…}

Vector<Widget> vw;

Widget bestWidget;

Vector<Widget>::iterator i=

find(vw.begin(), vw.begin()!=vw.end(),bestWidget)

Can we now re-write:

Class Widget{…}

typedef Vector<Widget> WidgetContainer; 

WidgetContainer wc;

Widget bestWidget;

WidgetContainer::iterator i=

find(wc.begin(), wc.begin()!=wc.end(),bestWidget)

Ok, wait.. we all know how to encapsulate and hide things !

Still, what’s the point….?

Use typedef (encapsulation) to enable write us container independent re-usable and maintainable code. Period!

Now, lets us say we have a:

Class CustomerList





 typedef list<Customer> CustomerContainer;

 typedef CustomerContainer::iterator Cciterator;


In the above code, the class hides all the internal implementation of the container hidden within itself yet the class straight forwardly is a list.

[Roll on.. Many years.. say 2025-hope c++ survives]

We realize that we no longer need to support the insert a customer at the middle. But, a new requirement to find the top 20% of the customers present comes in.

So, how do we then handle this new requirement still or without depreciating old functionality. We use n_th element algorithm but we need to change the container to vector or deque.  Hence, this gives us the freedom to not bother about implementation of the container inside our code.


Yay, we did a good job! we had encapsulated a container which can be  changed based on the requirements still its is done implicitly. So, to conclude to write complete container independent code is nearly impossible.

However, we could hide and do good job of encapsulating the implementation of container from the code and maintain them for future use.



Useful transitive words to write effectively

A list of transitive actions words to write effectively:

(Source: scrapped over internet-especially from academic websites)

To indicate more information

  • Besides – Making an additional point; anyway
  • Furthermore
  • In addition
  • Moreover
  • Likewise
  • Indeed – In truth
  • In fact
  • Also
  • As well
  • Foremost – Ranking above all others; Preceding all others in spatial position
  • First, Second, Third, Finally
  • Firstly, Secondly, Thirdly

To indicate an example

  • For example
  • For instance
  • In particular
  • Particularly – Specifically or especially distinguished from others
  • Specifically
  • To illustrate
  • To demonstrate

To indicate a cause or reason

  • Since
  • Because
  • Because of
  • Due to
  • For
  • For the reason that
  • As
  • Inasmuch as – Since
  • Whereby – As a result of which, By which, “the means whereby we achieved our goal”

To indicate a result or an effect

  • Accordingly – because of the reason given
  • Consequently
  • Hence
  • So
  • Therefore
  • Thus
  • Thusly – In the way indicated
  • Thence – From that fact or reason or as a result
  • Therefrom – From that circumstance or source
  • Thereof – Of or concerning this or that, From that circumstance or source
  • Corollary – A practical consequence that follows naturally, “blind jealousy is a frequent corollary of passionate love”

To conclude

  • For the aforementioned reasons
  • For the aforementioned reasons, there is no doubt that
  • To sum up the foregoing,
  • Given these facts
  • In conclusion
  • In closing
  • To conclude

To express an opinion

  • In all due fairness
  • With good judgment, (one/we may)

To describe or make

  • vivid
  • portray
  • depict
  • exhibit
  • illustrate
  • expose
  • present
  • paint a portrait
  • limn – Trace the shape of, make a portrait of
  • delineate
  • represent
  • demonstrate
  • constitute – Form or compose
  • embodied – (adj) Expressed by
  • embody – (v) Represent or express in tangible form
  • embodiment

To prove

  • manifest – Provide evidence for; stand as proof of
  • attest – Provide evidence for
  • testify – Provide evidence for
  • certify – Provide evidence for
  • endorse, indorse – Give support or one’s approval to
  • shew – Establish the validity of something, as by an example, explanation or experiment
  • establish
  • instance – (v) Clarify by giving an example of
  • exemplify – (v) Clarify by giving an example of

To compare or contrast

  • Whereas
  • In comparison
  • In contrast
  • However
  • Although
  • On the other hand
  • Likewise
  • Similarly
  • But
  • Yet
  • Withal – Despite anything to the contrary (usually following a concession)
  • Withal – Together with this
  • Nevertheless – Despite anything to the contrary
  • Nonetheless – Despite anything to the contrary
  • Notwithstanding – Despite anything to the contrary
  • Even so – Despite anything to the contrary
  • All the same – Despite anything to the contrary

To indicate time

  • After
  • Before
  • Currently
  • During
  • Eventually
  • Finally
  • First, Second, etc.
  • Formerly
  • Immediately
  • Initially
  • Lastly
  • Later
  • Meanwhile
  • Next
  • Once
  • Previously
  • Simultaneously
  • Soon
  • Subsequently
  • Subsequent – Following in time and order
  • Hitherto, Heretofore – Used in negative statement to describe a situation that has existed up to this point or up to the present time, “The sun hasn’t rose hitherto.”
  • In due time
  • Henceforth

To indicate certainty

  • Truly
  • Sincerely
  • Genuinely
  • Surely
  • Rightfully
  • Absolutely
  • Indubitably
  • Certainly
  • Without doubt
  • Needless to say

To indicate doubt

  • Most likely
  • More likely
  • Possibly
  • Probably
  • Dubitable – Open to doubt or suspicion
  • Dubious – Distressed with uncertainty or doubt

To summarize

  • Overall
  • To summarize
  • In summary
  • To sum up
  • Paraphrased
  • Briefly
  • In brief
  • Summing up
  • To put it briefly
  • précis – A sketchy summary, Make a summary (of)
  • synopsis – A sketchy summary
  • apercu – A short synopsis

To provide a condition

  • provision, proviso – A stipulated condition
  • stipulate – Specify as a condition or requirement in a contract
  • given
  • if
  • whether
  • whenever
  • when
  • while

To express positive words

  • magnificent
  • grandeur – The quality of being magnificent or splendid or grand, the quality of being exalted in character or ideals or conduct
  • magnanimous – The quality of being exalted in character or ideals or conduct
  • fantastic
  • fantastical
  • phenomenal
  • wonderful
  • extraordinary
  • marvelous
  • superb
  • good
  • fine
  • great
  • avid – Emotionally desirable
  • avid ambition to succeed
  • excellent
  • spectacular
  • prodigious
  • grand
  • brilliant
  • glorious – Bringing great happiness and thankfulness
  • illustrious – Widely known and esteemed
  • notable – Worthy of notice
  • respected
  • impressive
  • splendid
  • splendiferous – Having great beauty and splendor
  • resplendent – Having great beauty and splendor, Richly and brilliantly colorful
  • flamboyant – Elaborately or excessively ornamented, Richly and brilliantly colorful
  • redoubtable – Having or worthy of pride
  • formidable – Extremely impressive in strength or excellence
  • prowess
  • superior
  • terrific
  • tremendous
  • wondrous – Extraordinarily good
  • wonderful
  • sublime – Inspiring awe, Lifted up or set high
  • flair – natural talent
  • knack – A special way of doing something
  • outshine – Attract more attention and praise than others
  • paramount – Having superior power and influence
  • predominant
  • preponderating
  • prevailing

To show intelligence

  • profound
  • shrewd – hardheaded (practical experience and observation) intelligence
  • astute
  • acumen – Shrewdness shown by keen insight
  • insightful
  • savvy – The cognitive condition of someone who understands
  • cognition – The psychological result of perception, learning and reasoning
  • genius
  • smart
  • sharp
  • keen
  • mastermind
  • Einstein – Someone who has exceptional intellectual ability and originality
  • work of art
  • fine art
  • maven – Someone who is dazzlingly skilled in any field
  • mavin – Someone who is dazzlingly skilled in any field
  • adept – Someone who is dazzlingly skilled in any field
  • whiz – Someone who is dazzlingly skilled in any field
  • wizard – Someone who is dazzlingly skilled in any field

To intensify

  • incredibly
  • exceedingly
  • toppingly – extremely well
  • extremely
  • extraordinarily
  • truly
  • really
  • very
  • utterly – Completely and without qualification; used informally as intensifiers, With sublimity; in a sublime manner
  • absolutely
  • perfectly
  • sublimely
  • dramatically
  • sheer – (adj.) Complete and without restriction or qualification; sometimes used informally as an intensifier; (adv.) Directly “he fell sheer into the water”


  • enounced, enunciated – Speak, pronounce, or utter in a certain way
  • pronounced – Speak, pronounce, or utter in a certain way
  • articulated – Express or state clearly
  • vocalized – Express or state clearly
  • posited – Put firmly
  • stated
  • expressed
  • reported
  • alleged – Declared but not proved
  • averred – Report or maintain, To declare or affirm in a grave manner and formally as true
  • affirmed, asserted
  • wrote
  • composed
  • indited – Produce a literary work
  • penned – Produce a literary work
  • spelt – Indicate or signify
  • voiced, sounded – Give voice to
  • demean – Reduce in worth or character, usually verbally

Noted (said)

  • remarked
  • denoted – Be a sign or indication of, “Her smile denoted that she agreed”
  • observed
  • commented
  • mentioned
  • referred
  • announced
  • noticed


  • explicitly
  • accurately
  • expressly
  • exactly
  • incisively


  • innumerable
  • many
  • various
  • several
  • diverse
  • umpteen
  • umteen
  • myriad (noun and adj.)


  • extol – (v) Praise, glorify, or honor
  • exalt
  • glorify
  • laud
  • proclaim
  • revere
  • idolize
  • worship
  • venerate

Call Forth

  • evoke – Call forth (emotions, feelings, and responses)
  • arouse – Call forth (emotions, feelings, and responses)
  • elicit – Call forth (emotions, feelings, and responses)
  • enkindle – Call forth (emotions, feelings, and responses)
  • provoke – Call forth (emotions, feelings, and responses)
  • inflame – Arouse or excite feelings and passions
  • awake – Stop sleeping
  • conjure – Evoke or call forth, with or as if by magic
  • invoke – Evoke or call forth, with or as if by magic
  • summon – Gather or bring together
  • instill – deposit gradually


What are the characteristics of a bad software engineer?

SE Best Practices!!

This is a follow-up question to Product Managers: What are the characteristics of a bad product manager?.

View Question on Quora

Master Thesis Vs. Lectures-Feb 4

Well It seems quite a time, I had updated my last post on this Blog.

But now with solid grounds, I had started my M.Sc thesis in Cetecom telecommunication Lab in Germany.

I will write and share my whole experience throughout my Journey to solve the Problem of Non-linearity. How much it would improve empower Society by conducting research.

Few observations From transitioning from Lecture based to Independent based Learning:

 1) Materials need to be explored on self-study basis.

2) Reasoning skills play a major role to understand the problem and to look for the solution on the right direction.

3)Consumes time though it will be an enjoyable run.

4)Focusing on the smaller details will create a situation to handle the problem very efficiently.

On side with Academic Lectures:

A)Material will  be consolidated so less time to consume.

B) Need to think how Prof might have solved the problem.

C) “Exam prospective result is just credits but in thesis the goal makes us to push the Human race forward”…

Dresden Microelectronics Academy 2013-Inaugural

I’ve always wonder ‘Ain’t that cool to take a break for Summer school’.  Apparently, last week I got a opportunity to visit TU-Dresden(Technische Universitat), Germany. Microelectronics was always a fascinating thing which no one could less estimate because ‘Every chip counts for the computation we do with our computer’. The every nm(nanometre) of it’s size measures the capability of computation. As, We know breaking Moore’s law will be the next big thing in the silicon sector I just wanted ‘How industry experts try to solve Manufacturing and Moore’s law problem’.

Aside:though the event was held last week I din’t find time, So my write-up won’t be chronological & it is non-linear narrative !

Tada…. Now I am here in TU-Dresden!!

Day-1 (Inaugural and Meet up)

Impressions from the first Inaugural speech by Prof. Johann Bartha(TU-Dresden)


the cloud nine moment was when professor introduced different people form various University … Gladly I was the Only one from Saarland University.

Day went well with loads of talk and finally the awe moment ,, Yep,  the Music & sight seeing of City-Dresden.

Few clicks ….


Footnote on Hard working von Quora!

The best advice I’ve ever heard to a question like this was something like “No problem, don’t motivate yourself, stay a loser” (in Russian, not sure how good the translation is).

Asking advise from other people doesn’t work.


Browsing Internet and Quora doesn’t work. You just sit down and study for 12 hours per day. Or you don’t.  

This might sound harsh, but that’s pretty much what I started to do when I was in 8th grade, what I kept doing for the next ten years and more-or-less what I keep doing nowadays. And you know, I love it when people say “It’s easy for you, you’re so smart”. It isn’t easy, nowhere near that, but it’s worth the effort.

German ‘Punctuality’ -A view

Leaving other Stereotypes. Germans have the great culture of Discipline being‘PUNCTUAL’ it’s a timely gift possessed by the entire nation .

Few occasions to cite:

1. Business meetings- They would like to start the meetings on time irrespective of people. They don’t start early nor late but They start ‘On-time’.

2. It holds true for Family gathering apart , the Transit in Germany will  be consistent and on time 

                 [Image :Train to arrive the Bahnhof(station) on-time]

The Local ‘DB'(Deutsche Bahn) arrives on time . Despite it’s timing native Germans say they are inconsistent but compared to US standards they are quiet consistent.

Though,there exists many characters to define a German quality but personally ‘Punctuality’ defines there discipline , nature of work. work life balance etc..,

 ‘Time management’- Would be the take home lesson for everyone from Deutschland!

Walsh haldmard CDMA systems

Walsh codes (a.k.a Walsh-Hadamard codes) are a set of perfectly orthogonal codes used to separate users on the downlink (DL) channel in CDMA systems (for example in CDMA2000, UMTS cellular standards etc.). Code orthogonality between two codes W_i and W_j is defined as 

These codes can be generated iteratively. Here is a simple illustration of a binary Walsh code tree.

As you might notice, any two codes in the same level or codes in different branches (at different levels) are perfectly orthogonal (called OVSF codes – Orthogonal Variable Spreading Factor Codes). The different levels of the tree correspond to different spreading factors (SF) for the code (which translates to different data rates – higher SF->higher data rates). 

The code tree itself is easy to construct when you observe the pattern. If the code at a given level n is x (with SF 2^(n-1)), the codes generated at the next level n+1 are [x x] and [x -x] (with SF 2^n). You may also want to look into the construction of theWalsh matrix.

An important requirement to keep in mind for the orthogonality condition to work is that the codes must be synchronized in time and this is easier to achieve on the DL where a single base station is orthogonalizing multiple users in its cell area.

Aside: Walsh codes are also used for M-ary orthogonal modulation on the uplink (UL) channel for each user.

Blog at | The Baskerville Theme.

Up ↑


Get every new post delivered to your Inbox.

Join 64 other followers