Search

Android Development Principles | Guidelines

Getting started with Android development seems to be a big challenge. You’ve to have a deep understanding of android development principles and basic guidelines. Unfortunately, most of the developers don’t get the chance to learn the basics until it’s too late. If you’re just starting out, there are certain principles and guidelines that you’ve to stick to. What are these? Let’s dive in. Android development principles can be best explained by the SOLID acronym, as devised by Robert Martin. It refers to: Single Responsibility Open-Closed Principle Liskov Substitution Interface Segregation Dependency Inversion Robert Martin developed these five object-oriented design principles for the sole purpose of helping developers deliver maintainable and extensible systems. These principles not only help in writing a well-structured code but they also make sure that the code can easily be extended later. Take, for example, .NET. In the beginning, .NET was a mess and it were these principles that helped developers make a well formatted code for .NET applications and websites. So, let’s have a look at these principles individually. Single Responsibility Single Responsibility, as its name suggests, means that your classes should have only one responsibility. For example, if you have to perform calculations, mapping, and formatting, make 3 separate classes to handle each responsibly rather than making one class to handle all 3. But, what exactly do we mean by responsibility? A responsibility can be thought of as a “reason to change”. If you can think of more than one reason to change a class then you are probably breaking the Single Responsibility rule. The reason behind Single Responsibility is that it makes your class more complex and lead to code duplication issues which almost always ends up with non-updated codes. Open-Closed Principle           This means that your software entities like classes, functions, modules etc. should be open to extension but not modification. This is a very basic principle that should be followed no matter what platform you are coding for. This principle requires you to write a class or function or module in a way that it does need to be changed whenever your requirements change. For example, if you are making a class to calculate the area of a shape like a circle then you shouldn’t change the class every time a new shape comes as an input. Designing a base class and then extending it with the help of inheritance, or any other technique depending on the language you are using, is the way to go. This way, you won’t be making a change in the class for every new shape. Liskov Substitution Principle This is the type of a principle that is very tricky to explain even though almost all of us follow this principle unintentionally. Liskov Substitution Principle says that: “Objects should be replaceable with their subtype instances without having the need to alter the program.” This might be confusing but let me explain it with the help of an example. Let’s say you made a class that requires a List Object to perform a certain task. Now, what if we send an ArrayList Object to this class instead of a List Object? The class shouldn’t work right? No, the program will work just fine. The reason is the Liskov Substitution Principle. The ArrayList Object is a subtype of List class and, since, List class is an abstraction, the ArrayList Object will work without any problem. In short, you can replace the objects of List with any of its subtype without causing the program to break. So, if you require T and S in a subtype of T, then objects of T should be replaced by the objects of S without changing the properties of the program, especially the correctness property. Interface Segregation Principle This is a pretty straight forward principle. The Interface Segregation Principle states that there should be a lot of Client-specific User Interfaces rather than a general purpose User Interface. Let’s say a user has to enter his email address, fill a survey, and enter his favorite food. In this case, it would be better to make 3 separate User Interface pages instead of a single general purpose page that asks all of these questions. A general purpose User Interface will make your code complex because of the multiple callbacks as well as make the user confused. Remember, always give users small achievable goals rather than a big time-consuming task. Dependency Inversion Principle The Dependency Inversion Principle covers two things: High-level modules should be independent of the low-level modules. Both should depend on abstractions. Details should depend on Abstractions instead of Abstractions depending on the Details. You will be increasing the de-coupling by making your High-level modules independent of the low-level modules. Being a developer, you should know that requirements for an application changes a lot. And, changes are risky. So, making your modules independent will make them reusable as well as significantly reduce the risks involved in changing the implementations. In short, you will reduce the risk of changes by depending on the abstractions, for instance, interface rather than implementations. A few great tips for android developer that helps who wants to become one, you will undoubtedly have noticed that there are literally hundreds of thousands of apps on the Google Play store.
Rated 4.0/5 based on 20 customer reviews

Android Development Principles | Guidelines

422
Android Development Principles | Guidelines

Getting started with Android development seems to be a big challenge. You’ve to have a deep understanding of android development principles and basic guidelines. Unfortunately, most of the developers don’t get the chance to learn the basics until it’s too late. If you’re just starting out, there are certain principles and guidelines that you’ve to stick to. What are these?

Let’s dive in.

Android development principles can be best explained by the SOLID acronym, as devised by Robert Martin. It refers to:

  • Single Responsibility
  • Open-Closed Principle
  • Liskov Substitution
  • Interface Segregation
  • Dependency Inversion

Robert Martin developed these five object-oriented design principles for the sole purpose of helping developers deliver maintainable and extensible systems. These principles not only help in writing a well-structured code but they also make sure that the code can easily be extended later. Take, for example, .NET. In the beginning, .NET was a mess and it were these principles that helped developers make a well formatted code for .NET applications and websites.

So, let’s have a look at these principles individually.

Single Responsibility

Single Responsibility, as its name suggests, means that your classes should have only one responsibility. For example, if you have to perform calculations, mapping, and formatting, make 3 separate classes to handle each responsibly rather than making one class to handle all 3.

But, what exactly do we mean by responsibility? A responsibility can be thought of as a “reason to change”. If you can think of more than one reason to change a class then you are probably breaking the Single Responsibility rule.

The reason behind Single Responsibility is that it makes your class more complex and lead to code duplication issues which almost always ends up with non-updated codes.

Open-Closed Principle          

This means that your software entities like classes, functions, modules etc. should be open to extension but not modification.

This is a very basic principle that should be followed no matter what platform you are coding for. This principle requires you to write a class or function or module in a way that it does need to be changed whenever your requirements change.

For example, if you are making a class to calculate the area of a shape like a circle then you shouldn’t change the class every time a new shape comes as an input. Designing a base class and then extending it with the help of inheritance, or any other technique depending on the language you are using, is the way to go.

This way, you won’t be making a change in the class for every new shape.

Liskov Substitution Principle

This is the type of a principle that is very tricky to explain even though almost all of us follow this principle unintentionally.

Liskov Substitution Principle says that:

“Objects should be replaceable with their subtype instances without having the need to alter the program.”

This might be confusing but let me explain it with the help of an example.

Let’s say you made a class that requires a List Object to perform a certain task. Now, what if we send an ArrayList Object to this class instead of a List Object? The class shouldn’t work right?

No, the program will work just fine. The reason is the Liskov Substitution Principle.

The ArrayList Object is a subtype of List class and, since, List class is an abstraction, the ArrayList Object will work without any problem.

In short, you can replace the objects of List with any of its subtype without causing the program to break. So, if you require T and S in a subtype of T, then objects of T should be replaced by the objects of S without changing the properties of the program, especially the correctness property.

Interface Segregation Principle

This is a pretty straight forward principle. The Interface Segregation Principle states that there should be a lot of Client-specific User Interfaces rather than a general purpose User Interface.

Let’s say a user has to enter his email address, fill a survey, and enter his favorite food. In this case, it would be better to make 3 separate User Interface pages instead of a single general purpose page that asks all of these questions.

A general purpose User Interface will make your code complex because of the multiple callbacks as well as make the user confused. Remember, always give users small achievable goals rather than a big time-consuming task.

Dependency Inversion Principle

The Dependency Inversion Principle covers two things:

  • High-level modules should be independent of the low-level modules. Both should depend on abstractions.
  • Details should depend on Abstractions instead of Abstractions depending on the Details.

You will be increasing the de-coupling by making your High-level modules independent of the low-level modules. Being a developer, you should know that requirements for an application changes a lot. And, changes are risky.

So, making your modules independent will make them reusable as well as significantly reduce the risks involved in changing the implementations.

In short, you will reduce the risk of changes by depending on the abstractions, for instance, interface rather than implementations.

A few great tips for android developer that helps who wants to become one, you will undoubtedly have noticed that there are literally hundreds of thousands of apps on the Google Play store.

Sabih

Sabih Javed

Blog Author

Sabih Javed is a digital marketer, blogger, and a tech-geek. He is the founder of Digital Marketer PK where he publishes what he does. He is currently working with CounponBuffer as Marketing Manager.

Join the Discussion

Your email address will not be published. Required fields are marked *

Suggested Blogs

Six Tips To Improve As Android Developer

Mobile applications are increasing day by day and that is all because of increasing craze and trend of Android development course among individuals. Evolution of these mobile applications has given people an interesting and innovative ways to stay connected with each other. The statistics say it all, Android market leads the position with 2.2 million apps available for download (as of June 2016). With the numbers only we can tell the increased demand for Android developers. Digital era has already started and we are already witnessing the emerging market for these new age jobs. Android development surely has a bright future but with proper Android development training and certification will take you to new heights. As the market for Android development is booming, it is mandatory for an Android developers to have the proper skill set. Let’s explore some basic and essential tips to become a good Android developer. Design does matter One of the primary areas to concentrate on will be your app design. You might be having a great idea and proper skill sets to become an android developer, but if you fail in to attract people just because of bad execution of your ideas, it does not matter how creative your app is because people are not going to turn their heads towards poorly designed applications. Android platform should be your primary concern We know that this article is primarily for android developers, but this point is worth noting. iOS gets more premium quality apps than android (at least sooner than android) because iOS users do not worry about spending a few bucks on their apps, android users, on the other hand, are less targeted towards purchasing the apps. This should not stop you from developing applications for android, the reason being there are more than 1000 million android devices out there and you will be missing out millions of customers. Releasing applications for free “How do I make my money back then?” is the first question that pops into your mind. Well as said before, android users want their applications to be free and you can make your money back by using ads in your application. If this does not work for you, develop two different applications with slightly different features (premium and regular). The premium app should have slightly more features than the normal version and you can release it as paid version while as the normal app can be released for free with slightly fewer features or with ads. But remember this, DO NOT compromise on quality on either of the applications. Being passionate leads to better development Building something that can solve real life problems can help App developers to kick start the early traction. It requires passion and persistence which lacks in many developers. Developing better applications requires some persistence in the work. Treating yourself as the most important user of the application will work in your favour. If you are really passionate about creating something out of the box, persistence is the only way. Top App developers around the globe would still create apps even if they are not getting paid. Teaming Up We all know that having a team makes work better. Developing android applications is nothing but working in a small core team and creating it bit by bit. Technically sound people working together will faster the work. Applications have many aspects which can’t be dealt by a single person. Having a small technical team with well-coordinated people can make things really easy. Languages to Focus On: A successful android developer needs to be proficient in few programming languages which will help in developing better application. These languages consist of Java, SQL and XML. Developers should be well versed in Java as it is the most in-demand language. Creating an android application requires the database and he should be well-versed in SQL. XML works along with SQL and Java as it performs tasks like parsing data feeds, designing UI and more. The above-mentioned points should be given priority before developing any android apps, remember that there are several other ways for you to become a good android developer. Intensive research on developing applications is strongly recommended.
Rated 4.5/5 based on 22 customer reviews
Six Tips To Improve As Android Developer

Mobile applications are increasing day by day and ... Read More

Web Development Using PHP And MySQL

PHP (or PHP Hypertext Preprocessor) is a server-side scripting language that is used to create dynamic web pages that can interact with databases. It is a widely-used open source language that is specifically used for web application development and can be embedded within HTML. Why PHP? The distinguishing feature of PHP is that the scripting code is executed on the server, which generates HTML that is sent back to the client. The client receives the result of executing the script without knowing the underlying code. Developers can configure the web server to process all the HTML files (containing the PHP script). PHP course is easy to learn for any newcomer, but also offers advanced programming features. Using PHP with a database system PHP, as a scripting language, is popular among web developers because of its ability to interact with database systems including Oracle and MySQL. This article discusses the use of PHP scripting language with the MySQL database. Any website can require a variety of data or information to display and to retrieve them from the database. This can include display of a simple list to the running of the website based on data stored in the database. Listed below are some examples where PHP and MySQL can be used together: • Digital Ad banners, where the PHP script can be used to retrieve a digital banner from the database, which then selects a random banner from its table records and sends it back to the calling script. The PHP script can also maintain a count of banner views and clicks from the website. • Internet forums or digital boards, which use PHP and MySQL to store and retrieve user messages. • Website designing, where the design of an entire website can be changed using a couple of PHP scripts, instead of changing and uploading each web page. The PHP script can access the MySQL database to retrieve all information about the web page. Setting up the MySQL database The procedure of setting up the MySQL database varies according to the host. Every database would require a user name and password, in order to access the database. Database administration can be done using PHP scripts or using a program like PHPMyAdmin. The next step is to create the database tables for storing the website information. Creating a database table using PHPMyAdmin is also simple. Alternatively, one can create and configure the entire database using the following PHP script: CREATE TABLE tablename { Fields } Where the Fields are coded as fieldname type(length) extra_info Example: first varchar(15) NOT NULL The following command is used in the PHP script to connect to the MySQL database: mysql_connect(localhost,$username,$password); where: • localhost is the server address on which the web site is running, • $username is the user name for the database access • $password is the password for the database access Executing PHP commands After configuring and connecting to the MySQL database, you can start executing PHP commands on the server. Following are the 2 methods of executing a PHP command: • Entering the command in PHP using the following syntax: Mysql_query($query) This form of command can be used to repeat the command simply by changing the variable. • Defining the command as a variable. The result of the operation will be assigned to the variable. Data input and output Inserting data using PHP is identical to the procedure of data input using HTML pages. The advantage of using PHP is that the script does not need to be changed for each new piece of input data. Users can also input their own data on the web page. Following is an example of an HTML page with textboxes that can be used to enter data in a form: Alternatively, you can use variables to input information into the database. Example: $first=$_POST[‘first’]; $last=$_POST[‘last’]; $phone=$_POST[‘phone’]; $mobile=$_POST[‘mobile’]; $fax=$_POST[‘fax’]; $email=$_POST[’email’]; $web=$_POST[‘web’]; … $query = “INSERT INTO contacts VALUES (”,’$first’,’$last’,’$phone’,’$mobile’,’$fax’,’$email’,’$web’)”; mysql_query($query); This script is saved in the insert.php file, which can be called from the HTML form. Using this method, data entered in the web page form is stored in the defined variables, which are then passed to the PHP. To display (or output) the entered data using PHP, you can use the following MySQL command with the result assigned to the variable. $query=”SELECT * FROM contacts”; $result=mysql_query($query); PHP provides 2 submission methods, GET and POST to get the data submitted by the form into your PHP script. GET method displays the variables and the data in the page address, while they are invisible in the POST method. For example, a script can be created that will display different web pages depending on the clicked link. yourpage.php?user=david (to show David’s page) yourpage.php?user=tom (to show Tom’s page)
Rated 4.5/5 based on 9 customer reviews
3104
Web Development Using PHP And MySQL

PHP (or PHP Hypertext Preprocessor) is a server-si... Read More

Scala In Demand Technologies Built On Scala

The term Scala originated from “Scalable language” and it means that Scala grows with you. In recent times, Scala has attracted developers because it has enabled them to deliver things faster with fewer codes. Developers are now much more interested in having Scala training to excel in the big data field. The Scala community has grown over the years and it has now become a standard for enterprise, start-ups and universities alike. Scala is now being used by many companies and individuals to build their own new ideas. Play Framework, Akka, Apache Spark, etc are some of the tools and projects created using Scala. Scala is now the next wave of computation engines and more importance has been given to the speed processing rather than the size of the batch, and the ability to process event streaming in real-time. 1.Apache Spark Apache Spark can be considered as the replacement of MapReduce. In late 2013, Cloudera, the largest Hadoop vendor supported the idea of replacing MapReduce with Apache Spark. Spark is developed by AMPLab and it is a fast and general purpose engine for large-scale data processing. Spark effectively provides an alternative for Hadoop’s two stage MapReduce model. It has improved the performance of certain applications to 100 times with its fine grain operators, in-memory caching of intermediate data, and data flow optimization. 2. Scalding Scalding has been introduced and maintained by Twitter. It provides full benefits of Scala syntax and functional operations. Scala is a powerful language for solving functional problems. Scalding makes comprehensive use of Scala and it is an extension to cascading that enables application development with Scala. If we focus on the benefits of Scalding, data applications can be built with Scala. With simple and concise syntax code becomes easier to interpret. Scalding has filled the benefits of cascading application framework. 3. Apache Kafka Built and maintained by LinkedIn, Apache Kafka is a distributed streaming platform. Apache Kafka allows the user to publish and subscribe streams of data, just like a messaging system. Kafka is responsible for handling hundred of megabytes of read-write traffic per second from thousand of clients. It is also empowered by Scala and we can see the influence of the language. Real-time data pipelines and streaming apps can be built by using Apache Kafka. Yahoo Kafka Manager is also written in Scala and the web console is built using Play Framework. The Kafka Manager is being used by many teams including the Media Analytics team. It interacts with an actor-based, in-memory model built with Akka and Apache Curator. 4. Finagle Built by the people at twitter, Finagle can be considered as one of the best case using Scala. It is used to build high-concurrency servers and is an extensible RPC system for JVM. Finagle was intended to provide high performance, concurrency along with Scala and Java idiomatic APIs. Finagle is known for the optimal use of available system resources and high scalability through concurrency. It uses safe, simple and clean concurrent programming model which is based on Futures. All these results in safe and modular programs.
Rated 4.5/5 based on 20 customer reviews
Scala In Demand Technologies Built On Scala

The term Scala originated from “Scalable languag... Read More

Useful links