Adapter Design pattern [structural]

Motivation: When we need to adapt a framework but we cannot or do not want to modify its interface, yet we want to use it. The aim of the Adapter is to take the incompatible interface and adapt it to the one we need.

  • The Adapter should be used to make things work after they are designed.
  • Adapter is a right fit only when functionality is available but not in right interface.
  • Choose the adapter if you cannot change the source code of the incompatible type.
  • The Adapter is what actually adapts the incompatible interface to the one we require.
  • Don’t use an Adapter if you can modify the implementation.
  • You can also wrap the Adapter object in a dedicated Adapter class which exposes the API we need.

The Adapter pattern converts an existinginterface to another interface, which is required to make it compatible with the rest of the software system.

This pattern is useful when we need to integrate a component that provides similar functionality to other components in the system, but comes with an incompatible interface. 

Example: What do we do when we have a HDMI port on our laptop and we need to connect it to a monitor with VGA? We use an adapter or a converter.

Let’s say you need to build an Photo sharing app which edits a photo and shares it on all social media – but interface for each one is different with various parameters. Facebook has its own parameter list, Twitter has different set, Tumblr has a different set. So we write a common (adapter) interface instead of using different interface for each of them. This keeps your app code clean and readable.

Summary: The Adapter pattern converts an incompatible interface into one that we need. The adapter can save us from a lot of refactoring work when integrating incompatible interfaces. By using the Adapter, we do not have to refactor our code to use the adaptee’s (framework’s) incompatible interface.

A common mistake we do is trying to adapt a component which does not provide the required functionality.

 

Design Patterns: Importance and its Limitations

Advantages of Design patterns:

  • Reusability in countless projects to solve problems with a common pattern
  • Spend less time figuring out how to solve a particular issue
  • Spend a safe time on implementing the solution and improve the quality of the software product
  • Provides more value for the money
  • Proven solution – Extending or enhancing a software system that relies on well-established design patterns is easier
  • Refactoring your code base also means that you introduce new bugs
  • Reduces the risk of implementing solutions that only work in the short-term.
  • Lessen the need for frequent changes by using design patterns

Limitations

  • Whether or not to use a design pattern can be a tough decision.
  • Due to their generic nature, design patterns may not be able to address specific issues. In such cases, you will need to adapt them and change their implementation to fit your particular needs.
  • A certain level of expertise is required to implement design patterns correctly.
  • Unexperienced teams may fail to implement them properly, which can lead to bugs and unexpected delays.  

Things to tick off in 2019

With 2018 ending on a high note I want to make 2019 even better. With that in mind and also taking into consideration of becoming a parent (which literally means less time) I needed a set of most important things to be accomplished in 2019.

This list is still in works but I have figured out what is needed for at least the first month to a quarter or two:

  • Build complete solutions or components for a bigger solution
  • Build a web app using Spring framework
  • Refresh on Java, its collections usages
  • Dive into React for the web (not for mobile)
  • Refresh data structures and related algorithms
  • More understanding of design patterns and principles

Other things which spans across the whole year are:

  • Build my own WordPress site & start hosting
  • Complete my Github profile page
  • More blogging monthly twice or weekly once
  • More streaming
  • Start podcasting – create themes or series of episodes
  • Vlog on things I have learned weekly or fortnightly or monthly

Looking forward to an amazing 2019.

2018 in review

2018 was very good for me in all aspects of my life. I learnt so many new tech stuff. My financial goals were achieved more than what i thought and during the last quarter I got promoted as a father of beautiful human being.

Here is my list of things I achieved on 2018 on the career front.

  • Learnt Angular js – built a small front-end app
  • Built couple of basic Android apps as part of a course
  • Started with basics of Machine Learning (Statistics)
  • Enhanced my swift programming skills
  • Back on macOS native application development
  • Refreshed my C++ skills updated on C++11, 14, 17 standards

From a extra-curricular things,

  • I started streaming my side project works.
  • Started a youtube channel
  • Planned for a podcast channel but did not make effort to work it out
  • Working on my communications
  • Started read eBooks on Kindle and iBook
  • Kept this blog live on an average of 50+ visitors per month

From a health and fitness side,

  • Started doing yoga though not consistent but weekly 3-4 days
  • Learnt Sudarshan Kriya from Art of Living

Hopefully I will exceed this list for 2019 and stick to my plan to explore paths which I haven’t traveled yet.

AWS in 5 minutes

This post will give you a basic understanding of what Amazon Web Service is, how components in it works, what each component is responsible for at a very high level – all these in just 5 minutes.

This post is gives you a brief idea about the components used in aws. This will surely help you understand things when aws developers are discussing about topics and issues while at work.

EC2Elastic Cloud Computing instance is where you run your web app server or a micro-service server. This is one of the primary component of AWS. You can create multiple instances of the servers in multiple availability zone so that if one zone goes down your services to end users are not affected. Session maintainence can be configured here or in ELB

ELBElastic load balanacer automatically distributes incoming application traffic across multiple targets. It handles the traffic coming from the public networks (users/mobile/consumers). The major functionality of this component is route the traffic to different servers balancing the load from incoming traffic. It can handle the varying load of your application traffic in a single Availability Zone or across multiple Availability Zones.

ELB facing the public network will be inside a public subnet to make it accessible. Apart from this and S3 instance all other components will be inaccessible to public as they will be configured with private subnet. This would be the best place to have session stickiness.

S3Simple Storage Service is used for storing all static files like documents, audio, video, image files. This service is only used for storing and retrieving the files. Glacier is used in connection to S3 to archive the least used or unused files to reduce the storage space.

AWS
The diagram represents typical web app architecture using some of the important components of amazon web services. Also shows the interactions between the components.

DataBases:

RDSRelational DataBase is the place where you store and manage your application data. This service supports RDBMS solutions like MySQL, etc. This service also supports the Master-Slave architectures.

NoSQL DB are used if web app solution needs a document based databases like DynamoDB, etc.

Security Group – is used to manage the access to service anyone can have. Each service must ideally have a security group defined.

Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service. It is designed to give developers and businesses a way to route end users to your application servers.

IAMIdentity and Access Management is the one where you can add/update/delete users and their permissions. Generally there will be end users, administrators, developers.

Elastic Cache is a managed, in-memory data store services. You can choose Redis or Memcached to power real-time applications. ElastiCache is a popular choice for Gaming, Ad-Tech, Financial Services, Healthcare, and IoT apps.

For administrators: CloudWatch monitoring service for AWS cloud resources and the applications you run on AWS. It keeps an eye your whole setup and triggers a notification using SNS service to email the administrators if there arises any warning or alert on servers using SES service.

Lambda services are generally used for solutions designed with serverless architectures.

Hope this would be useful to in one or the other way, at least giving you a sneak peak about what AWS is all about.

The 5 minute series

As mentioned in my previous blogpost the first among my targets this year is to start a 5 minute series to get introduced to anything. With this post I am listing down my initial set of topics which I will be writing on. This list will grow periodically and also will be updated with the links to each 5 minute series.

Following are the topics for which I am planning to do 5 minute introductions this year

I will be adding more to this list I finish each one.

This is the first time I am doing a 5 minute series. So your comments and suggestions are very very important to me. All criticism is taken up for improvement of such tutorials.