Showing posts with label Programing language. Show all posts
Showing posts with label Programing language. Show all posts

Sunday, 22 October 2017

10 Common Software Architectural Patterns in a nutshell

Ever wondered how large enterprise scale systems are designed? Before major software development starts, we have to choose a suitable architecture that will provide us with the desired functionality and quality attributes. Hence, we should understand different architectures, before applying them to our design.


What is an Architectural Pattern?
According to Wikipedia,

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope.

In this article, It briefly explaining the following 10 common architectural patterns with their usage, pros, and cons.
  1. Layered pattern
  2. Client-server pattern
  3. Master-slave pattern
  4. Pipe-filter pattern
  5. Broker pattern
  6. Peer-to-peer pattern
  7. Event-bus pattern
  8. Model-view-controller pattern
  9. Blackboard pattern
  10. Interpreter pattern 


1. Layered pattern
This pattern is also known as n-tier architecture pattern. It can be used to structure programs that can be decomposed into groups of subtasks, each of which is at a particular level of abstraction. Each layer provides services to the next higher layer.
The most commonly found 4 layers of a general information system are as follows.
  • Presentation layer (also known as UI layer)
  • Application layer (also known as service layer)
  • Business logic layer (also known as domain layer)
  • Data access layer (also known as persistence layer)
Usage
  • General desktop applications.
  • E-commerce web applications.
   


2. Client-server pattern
This pattern consists of two parties; a server and multiple clients. The server component will provide services to multiple client components. Clients request services from the server and the server provides relevant services to those clients. Furthermore, the server continues to listen to client requests.
Usage
  • Online applications such as email, document sharing, and banking.

3. Master-slave pattern
This pattern consists of two parties; master and slaves. The master component distributes the work among identical slave components and computes a final result from the results which the slaves return.
Usage
  • In database replication, the master database is regarded as the authoritative source, and the slave databases are synchronized to it.
  • Peripherals connected to a bus in a computer system (master and slave drives).


4. Pipe-filter pattern
This pattern can be used to structure systems which produce and process a stream of data. Each processing step is enclosed within a filter component. Data to be processed is passed through pipes. These pipes can be used for buffering or for synchronization purposes.
Usage
  • Compilers. The consecutive filters perform lexical analysis, parsing, semantic analysis, and code generation.
  • Workflows in bioinformatics.


5. Broker pattern
This pattern is used to structure distributed systems with decoupled components. These components can interact with each other by remote service invocations. A broker component is responsible for the coordination of communication among components.
Servers publish their capabilities (services and characteristics) to a broker. Clients request a service from the broker, and the broker then redirects the client to a suitable service from its registry.
Usage
  • Message broker software such as Apache ActiveMQ, Apache Kafka, RabbitMQ and JBoss Messaging.


6. Peer-to-peer pattern
In this pattern, individual components are known as peers. Peers may function both as a client, requesting services from other peers, and as a server, providing services to other peers. A peer may act as a client or as a server or as both, and it can change its role dynamically with time.
Usage
  • File-sharing networks such as Gnutella and G2)
  • Multimedia protocols such as P2PTV and PDTP.
  • Proprietary multimedia applications such as Spotify.
7. Event-bus pattern
This pattern primarily deals with events and has 4 major components; event source, event listener, channel and event bus. Sources publish messages to particular channels on an event bus. Listeners subscribe to particular channels. Listeners are notified of messages that are published to a channel to which they have subscribed before.
Usage
  • Android development
  • Notification services

8. Model-view-controller pattern

This pattern, also known as MVC pattern, divides an interactive application into 3 parts as,
model — contains the core functionality and data
view — displays the information to the user (more than one view may be defined)
controller — handles the input from the user
This is done to separate internal representations of information from the ways information is presented to, and accepted from, the user. It decouples components and allows efficient code reuse.
Usage
  • Architecture for World Wide Web applications in major programming languages.
  • Web frameworks such as Django and Rails.



9. Blackboard pattern
This pattern is useful for problems for which no deterministic solution strategies are known. The blackboard pattern consists of 3 main components.
blackboard — a structured global memory containing objects from the solution space
knowledge source — specialized modules with their own representation
control component — selects, configures and executes modules.
All the components have access to the blackboard. Components may produce new data objects that are added to the blackboard. Components look for particular kinds of data on the blackboard and may find these by pattern matching with the existing knowledge source.
Usage
  • Speech recognition
  • Vehicle identification and tracking
  • Protein structure identification
  • Sonar signals interpretation.

10. Interpreter pattern
This pattern is used for designing a component that interprets programs written in a dedicated language. It mainly specifies how to evaluate lines of programs, known as sentences or expressions written in a particular language. The basic idea is to have a class for each symbol of the language.
Usage
  • Database query languages such as SQL.
  • Languages used to describe communication protocols.


Comparison of Architectural Patterns
The table given below summarizes the pros and cons of each architectural pattern.

(click on image to enlarge)

Saturday, 14 October 2017

9 Interesting facts about Python Programming language

1.There is actually a poem written by Tim Peters named as THE ZEN OF PYTHON which can be read by just writing "import this" in the interpreter.


2.One can use an “else” clause with a “for” loop in Python. It’s a special type of syntax that executes only if the for loop exits naturally, without any break statements.



3.In Python, everything is done by reference. It doesn’t support pointers.

4.Function Argument Unpacking is another awesome feature of Python. One can unpack a list or a dictionary as function arguments using * and ** respectively. This is commonly known as the Splat operator. Example here



5.Want to find the index inside a for loop? Wrap an iterable with ‘enumerate’ and it will yield the item along with its index. See this code snippet



6.One can chain comparison operators in Python answer= 1<x<10 is executable in Python. More examples here



7.We can’t define Infinities right? But wait! Not for Python. See this amazing example


8.Instead of building a list with a loop, one can build it more concisely with a list comprehension. See this code for more understanding.

9. Finally, Python’s special Slice Operator. It is a way to get items from lists, as well as change them. See this code snippet



Monday, 25 September 2017

What is new in Java 9?

Java 9 is the evolutionary upgrade over its previous version 8 ( including every procedural update ). It's not like a major “groundbreaking” update like 7th but if you could use the “linking of the modules” then it's good for you.Here is some information about it (Java Platform, Standard Edition ) and you can dig out some more use out of this update.
Java 9 has several changes and it would be an extremely long answer if I were to list all of them.

However, there are some changes, which will impact how you program in Java 9. I list some of them below. However, the description will generally be short, as you can research most of them if you want.

1.The Process API changes

If you’ve ever tried accessing native processes running on the system, you’d probably know that Java didn’t use to be good at this. You would have to resort to C++ or C to manage the processes. With Java 9, you’d hardly ever use native code to manage processes.

2.Support for HTTP/2

With this, we finally let go of the legacy class Http URLConnection. It had several problems, however, the one which troubled the most was that used outdated technology based on protocols like FTP and gopher which are no longer in use.

3.Better Stack Traces

Nothing much to say here, just that it is a lot more organized than before. Also, you have the new StackWalker class, with which you can navigate your stack traces through the code, without String Manipulations.

4.Better Javadocs

This is one of my favorites. The Javadocs finally get a search bar, that means I don’t have to use Google to visit the documentation of the class.

5.Supports Unicode 8

Unicode 7 is the latest version of Unicode.

6.Modularity

This can’t be explained very simply, to be honest. It basically “divides the JDK into a set of modules that can be combined at compile time, build time, and run time into a variety of configurations”. To be honest, even I don’t understand it completely.

7.Better String Concatenations

Right now, if you do something like ”A” + “B”, in the bytecode, you have a StringBuffer. While this is a good option, it still has performance issues. Java 9 attempts to fix that.

8.JShell

This is what got most of us excited. No need to make classes, typing code directly into the command prompt. Java has finally got REPL.

9.Compile time improvements

Classes will tend to compile a lot quicker.

10.Javafx improvements

I haven’t actually tried this yet, but several UI Controls and the CSS API have seen a major upgrade.

11.Applets are finally depreciated

This made me happy the most. Finally can schools stop teaching something which has absolutely no future.

12.Parser API for Nashorn

Self explanatory.

13.Compact Strings

“Improve the space efficiency of the String class and related classes while maintaining performance in most scenarios and preserving full compatibility for all related Java and native interfaces.”

14.Project Coin

You can longer use only `_` as a variable name. This used to give a warning in Java 8, but generates an error in Java 9

Top 10 Programming Languages in 2017

Programming is something vast and rather individual as each developer chooses tools that are most convenient for them. However, certain languages, platforms, and frameworks have claimed themselves as one of the easiest and most efficient to use. Thus we have collected for you top-10 programming languages loved by developers nowadays. Which one is your favorite?

1.Python

Python is a dynamic and general-purpose language that emphasizes code readability and enables developers to use fewer lines of code (in comparison with Java or C++).

                         
It supports multiple programming paradigms and has a large standard library.
Developers love this language for clear syntax, good OOP support and great shortcuts.


2.C

C is a general-purpose imperative language that supports structured programming, recursion, and lexical variable scope. It is designed to encourage cross-platform programming and is available on many platforms.


This language is valued for being clear, providing access to hardware and making it possible to create tiny binaries.


3. Java


Java is one the leading choices among developers all over the world. This language is object-oriented and class-based and follows the “WORA” principle: write once, run anywhere.


People love Java for its concurrency (comparing it to be better than Python, for example), great variety of libraries and steadily good performance. The community is huge as well, meaning Java fans can always get a lot of support.

4.C++

This language is compiled, imperative and program-oriented and allows low-level memory manipulation. C++ influenced a number of other languages, such as C# or Java and is used for a variety of purposes.

Its key features that make it stand out are strong, static type system (making it possible to catch more errors within a compile time), ability to use it in a few programming styles, good performance, and expressiveness.


5.C#

C Sharp has seen an increase in popularity over the last year. It is an object-oriented and multi-paradigm language that encompasses many disciplines. C# was developed by Microsoft and is designated for the Common Language Infrastructure.


Though it is not so widespread as Java or Python, C# has its fans who appreciate the lack of headers, macros and templates, the presence of LINQ and anonymous types.


6.R

This is an open source language for statistical computing and it is very popular among data miners and statisticians. This language is a GNU package.


The R pros include its package ecosystem and its vastness and all the charting benefits.

7. JavaScript

JS is an object-based and dynamic language and is one of the core technologies of WWW content production. Even though some people tend to think Java and JS are the same (or at least, very similar) languages, JavaScript was influenced mostly by Self and Scheme.





JavaScript is seeing a rise in popularity and is included in hottest web development trends for the year 2017.

8. PHP

It’s a server-side and general-purpose language designed for web development. PHP is considered rather easy to learn and is often chosen by junior developers.

As well developers love that it’s portable, has a lot of high-quality solutions for an array of web problems and has a lot of frameworks.

9.Go

Go was created at Google and is an open-source language. It’s compiled and has such features as garbage collection, memory safety and limited structural typing.

It is really a good choice if you work with network applications and web servers. Go also consistently behaves across platforms, which is also a good feature.

10.Swift


Swift is a multi-paradigm language developed by Apple and is one of the top choices among iOS developers. It supports such concepts as late binding, extensible programming and dynamic dispatch.

Even though Swift is a relatively new language, it also saw rise in popularity in 2017 and overall looks quite promising.