Category Archives: Software Engg

Learn Functional Programming Before Java Lambdas, Functional Interfaces

As Java 8 got out-of-door, I wanted to quickly get on board with understanding and writing Lambda expressions and functional interfaces. But it was not easy like previous Java versions. And, the primary reason is the different programming paradigm one needs to understand in order to make use of Java Lambdas and functional interfaces concepts. And, this programming paradigm is functional programming. In one of the pages on functional programming (FP) I came across, it spoke about the change in thinking/mindset one, especially OOP developer, needs to bring in order to do a great job with functional programming. This is primarily because in OOP world, objects are first class citizens …

Continue reading

Posted in Programming. Tagged with .

Java Unit Testing Interview Questions

ATG interview questions

The article presents some of the frequently asked interview questions in relation with unit testing with Java code. Please suggest other questions tthat you came across and I shall include in the list below. What is unit testing? Which unit testing framework did you use? What are some of the common Java unit testing frameworks? Ans: Read the definition of Unit testing on Wikipedia page for unit testing. Simply speaking, unit testing is about testing a block of code in isolation. There are two popular unit testing framework in Java named as Junit, TestNG.   In SDLC, When is the right time to start writing unit tests? Ans: Test-along if …

Continue reading

Posted in Interview questions, Unit Testing. Tagged with , , .

Test-Driven Development (TDD) Shines with Mocking

The article presents a perspective and some code samples on how one could some cool stuff with Test-driven development (TDD) and Mocking. The code samples are done in Java. Lets briefly understand what is TDD and mocking? What is TDD? Test-driven development, simply speaking, is a software development process in which developers write tests first and, then writing enough code to pass those tests. Once all of the tests pass, they do code refactoring to enhance code quality. Following are key advantages of adopting TDD as your development process: Enforces the developers to thoroughly think through various different test cases which could be used to test the functional/business requirements. It, …

Continue reading

Posted in Unit Testing. Tagged with , .

Law of Demeter Coding Violations & How to Fix Them

The article lists down Law of Demeter Violations and presents solutions on how to fix them. The code samples are written in Java. Feel free to share your comment, if any. What is Law of Demeter Principle? There are several good pages on the web which could be read to understand the object-oriented principle, Law of Demeter. Following are some of them: Demeter: It’s not just a good idea. It’s the law. Object-Oriented Programming: An Objective Sense of Style PMB Coding Violations The group of programmers working on a Demeter system, back in 1980, came up with this programming principle which they termed as Law of Demeter. According to them, …

Continue reading

Posted in Software Quality. Tagged with , .

Unit Tests – Mocking vs Stubbing Vs Spying

The article lists down some good reads (from different webpages on internet) on unit testing concepts such as mocking, stubbing and spying and represents summarized information on these concepts. Mocks Aren’t Stubs What’s the difference between a mock & stub? Mocking vs. Spying in mocking frameworks Mocking and stubbing in Ruby on Rails What’s the difference between faking, mocking, and stubbing? After going through all the above pages, I could arrive at following definitions: Mocking Mocking is a unit testing phenomenon which is used to replace real objects with test objects that mocks the behavior. These test objects are called as Mock objects. The point to note is that mock …

Continue reading

Posted in Unit Testing. Tagged with .

Top 5 Unit Testing Best Practices

The article lists down top 5 unit testing best practices that one could adopt to be able to write great unit tests with greater code coverage. Test-Along, if not Test-Driven Many a times, rookies have been found to start writing unit tests once they have written most of the code, e.g., towards the end of the coding. However, to make the most of unit tests, one should write them as they write the code. This is somewhat different and less difficult than writing tests first and code later as in test-driven development (TDD). Following are some of the advantages of doing “test-along” development: One could achieve greater code coverage by …

Continue reading

Posted in Unit Testing. Tagged with .

Junit & Mock Framework Mockito Code Samples – Part 1

The article represents code samples for Junit tests and Mockito, a mocking framework. In addition, it describes different aspects of unit testing and mocking. Software Requirement The goal is to create a simple piece of software which caters to the requirement of school admission where in applicants submit their admission application.   Class Design & JUnit Tests To meet above requirement, following different component is designed: Core Components (Key Ones) AdmissionApplication.java: Consists of method recordNewApplication which validates the submitted application, and later, stores in the database after successful validation. ApplicationValidation.java: Consists of methods for validating business rules associated with admission such as mandatory inputs (first name, last name, class, gender, …

Continue reading

Posted in Unit Testing. Tagged with , .

JUnit Tests Code Samples for Testing Exception Scenarios

The article presents an example of unit tests which tests both happy path and exception scenario. Business Requirement User trying to open an account must be validated against the business rules related with users’ registration. Following are different business rules: User must provide a valid email address User must provide his first name User’s age must be 18 and above   Class Design To demonstrate the unit tests with happy and exception scenarios, following classes have been shown below: SignupValidation: Consists of code validating business rules SignupException: Custom exception representing Signup business rules failure EmailValidator (Get the code from this page). SignupValidationTests: Unit tests for testing signup validation code Class …

Continue reading

Posted in Unit Testing. Tagged with .

Unit Tests – An Alternate Functional Requirements Documentation

The article presents a perspective on how unit tests could be written in a way that they could be used as an alternate form of documentation for understanding functional requirements. Many a times, it has been found that developers, primarily rookies, did not have a clarity on how to name unit tests. Thus, many of them have been found to name the unit tests such as testXXX where XXX is name of the method which they wanted to tests. There has been many recommendations on how to name unit tests, some of which are following: Given…When…Then… Check the page by Martin Fowler (http://martinfowler.com/bliki/GivenWhenThen.html) WhenXXX_ExpectYYY Names representing different use case scenarios …

Continue reading

Posted in Unit Testing. Tagged with .

Content Framework for Lunch & Learn Sessions on IT Applications

The article represents a framework using which one could plan their content for taking an introductory session on their applications. The primary objective of such presentation is to provide the audience with following information: Business overview Applications overview The proposed framework aims to satisfy the education needs for different stakeholders including delivery manager, project manager, development & testing teams. Presenters talked differently In my recent experience, I attended a series of sessions taken by leads of different project teams working for the same customer. Except for few of them, most of these sessions were not very interesting and audience enjoyed lunches more than the sessions. Following are some of the …

Continue reading

Posted in Software Engg.

APIs Performance Testing with Twitter Iago

The article talks about performance testing tool, Iago, which is created at Twitter for testing their core database interfaces, storage sub-systems and domain logic, up to the systems accepting front end web requests. Performance requirement of Twitter platform? Simply speaking, end users expect to read & post tweets with a very fast response time and, Twitter is expected to respond in that manner irrespective of load arriving at it with absolutely no room for any slowness, whatsoever. That is a tough one, isn’t it? This is unlike many enterprise business systems where users can be a little forgiving by waiting for the response to show up. So, they needed to …

Continue reading

Posted in Performance Engineering. Tagged with , .

How to Measure Software Development Productivity

The article lists down pages/papers on measuring software development productivity. The Theory of Constraints: A good read on measuring software development productivity Measuring Productivity of Software Development Teams: The paper lists down different techniques/models for measuring software development productivity. CannotMeasureProductivity: Then, there is this article by Martin Fowler which says that it is difficult to measure software development productivity. He points about ineffectiveness of following approaches of measuring developer’s productivity: Lines of codes (LOC) Function points The software development teams working based on Waterfall model or Agile methodologies model tend to measure the developer’s productivity in terms of following variants: Function Points Story Points (size) vs Velocity Following pages present …

Continue reading

Posted in Software Engg, Software Quality. Tagged with .

Why Amazon.com Pages Rely on DNS Pre-fetch

The article presents a perspective on why Amazon.com pages rely on DNS pre-fetch and what other e-commerce websites could learn from this.   Whats Happening Under the Hood? As you do the view source of the homepage, amazon.com, you would find following Javascript code snippet, right at the top of the page:   <meta http-equiv=”x-dns-prefetch-control” content=”on”> <link rel=”dns-prefetch” href=”http://g-ecx.images-amazon.com”> <link rel=”dns-prefetch” href=”http://z-ecx.images-amazon.com”> <link rel=”dns-prefetch” href=”http://ecx.images-amazon.com”> <link rel=”dns-prefetch” href=”http://completion.amazon.com”> <link rel=”dns-prefetch” href=”http://fls-na.amazon.com”>   Later, in the same page as well as other pages, you would find several resources such as images, Javascript, CSS files accessed from one of the above as base URLs. So, let’s try and explore some of the …

Continue reading

Posted in Performance Engineering. Tagged with , .

Data Architecture Lessons from LinkedIn.com Data Handling Mechanisms

The article aims to describe how data is managed at LinkedIn.com, the most popular professional social networking site.  Please shout out loud if you disagree with one or more of the aspects mentioned below. Also, do suggest if I missed on one or more aspects. Data use-cases at LinkedIn.com Following are some of the data use-cases that we may have come across while we are surfing various different LinkedIn pages: Update your profile, and the same appears in recruiter search in near real-time. Update your profile and same appears as network connections  in near real-time. Share an update, and same appears on others news feed page  in near real-time. Then, there are …

Continue reading

Posted in Architecture, Performance Engineering. Tagged with , , .

Developers Playgrounds to Play & Learn

The article lists down the details around different programming playgrounds that could be used by developers to learn while playing with different technologies (programming languages & APIs). What are Developers Playground? Developers playground are online applications that facilitates enhanced learning of different programming languages/API by providing developers with the IDEs like development platforms where different programs could be written and executed side-by-side and results could be studied/examined. Following is the broad classification of such playgrounds. Programming Playground In playgrounds related with programming languages, developers could learn languages while doing the coding and see the output side-by-side. Following are some of the programming playgrounds: Codecademy.com (It also presents playground for APIs …

Continue reading

Posted in API Development, Software Engg. Tagged with , .

Artificial Intelligence – Where to Put Your Time & Money

As I looked around some of the artificial intelligence (AI) related acquisitions in last few years, I got convinced, at least, on the fact that majority of large companies such as Google, Facebook, IBM are seeing various different artificial intelligence topics to play a key role in impacting end users’ life (and hence, developers) in the future. With that as the background, it gave me good enough reasons to start doing research in relation with following: As students, what topics of artificial intelligence should they take up as one of their computer science courses while  selecting under-graduate & post graduate courses? As developers/programmers, what topics of artificial intelligence should they …

Continue reading

Posted in Artificial Intelligence. Tagged with .