Posts

Multi-level Marketing Solution for Masses - FYP Idea

"Multi-level marketing (MLM) is a marketing strategy in which the sales force is compensated not only for sales they personally generate, but also for the sales of the other salespeople that they recruit."[wikipedia] Companies that implements MLM strategy, ask you to become their member by purchasing a product and bring other people to buy their products. When new member joins with your reference, the company pays you specific amount from the membership fee or from the profit they earned from the product sold. When your referred person introduces a another member, the profit is shared not only with him, but with you too, sometime even with the complete hierarchy from the first person. The beauty of this model is, each client becomes marketer. This is also known as referral marketing and network marketing. Suppose, you have products to sell. Under MLM strategy, you assign referral number to each client, and ask them to market the products and introduce each client with thei...

Targeted News Subscription - FYP Idea

Its first post under FYP Ideas tag. Most of these ideas are my own, I share because I have other interesting things to work on. Don't undervalue by thinking why someone have shared if its so good. 2nd, it may be already implemented, so must check the web/mobile apps first before finalizing.   Targeted News Subscription  We usually want to read the news of our interest from newspapers. But the issue is, we have to browse through all newspaper to search those news. We have limited time, so we end up reading just one or two newspapers. Hence we miss a lot of news of interest in other newspapers. Reading just one newspaper deeply also takes a lot of time. The idea is to crawl and parse different news websites daily and categories each news for already defined keywords. These keywords may be anything possible from politician names, MNAs, ministries, players, cities, or news categories like political, education, cricket, football, dramas, or even movie star names. In shor...

Using Protected Access Modifier Correctly in Java

The attributes or methods with protected access modifier in parent class are inherited in subclass, hence the subclass can access them. When the subclass or parent class object is created in a class that reside in different package, we can not access the protected attributes from the object reference. So protected access modifier works like private as far access from user-classes (i.e. where we instantiate an object of that class) are concern. It works like public as far inheritance is concern, as its accessible in subclass code. That is why it comes between private and public access. So here comes a fundamental question, should we make our instance attributes protected if we want to make them available to subclasses? From good software design perspective, the straight answer is BIG NO, we should not make the instance attributes protected even if we want to make them inheritable, why? For the same reason as discussed in previous sections i.e. it breaks the encapsulation principle,...

Role of Access Modifiers in Java Inheritance

What methods or instance attributes are inherited is decided by their access modifiers in parent class. Private attributes and methods are not inherited in subclasses. All public attributes and methods are inherited in sub-classes. So you noticed, by making ID and name private in Person class, we stopped their direct availability in subclass Student. And by making get/set methods public for both attributes, we allowed Student class to read/update the inherited attributes without violating the encapsulation principle. I hope you already know, if a class contains some public methods/attributes, they can be called or accesses from reference of that class's object, no matter where the object of that class is created e.g. a static main method or any where else. There is another access modifier which is specially used with inheritance, its called protected . Protected access modifier is lighter than private but stronger than public access. Protected attributes or methods in parent cl...

Inheritance without Compromising Encapsulation

Encapsulation is another very important concept in OOP that states, a class must hide its data from other software components and should not allow reading or writing instance attributes directly. And this access must be given via public get and set methods. (I would share the Encapsulation in separate article). If you see the Student constructor, we have clearly violated the encapsulation principle for the inherited attributes by accessing those attributes directly. So a better design would making the ID and name attribute private in Person class and allow the subclasses to initialize them via parent class constructor. Lets see the updated code again: package com.bitspedia.java.inheritance; public class Person { private int ID; private String name; public Person() { } public Person(int ID, String name) { this.ID = ID; this.name = name; } public int getID() { return ID; } public void setID(int ID) { this.ID = ...

How Inheritance Works in Java - Basic Sample Code

I hope you have well understood the basic objective and benefits of using inheritance from my previous article , in this article we would see simple example code. Let us assume we are building an information system to manage different operations in an academic institution. It would involve different type of entities e.g. students, teachers, managers, etc. Lets define a general component i.e. Person first, the Person class would hold the common attributes of different type of related entities. Lets see how it would look like: package com.bitspedia.java.inheritance; public class Person { int ID; String name; } We have defined ID and name attribute because these are common among student, teacher and manager. So we can create Student class by inheriting it from Person class. In this way we add only those attributes in Student which are not present in Person class. Because, the attributes in Person class would be inherited in Student class. Here is the student class: pack...

Java Database Connectivity JDBC using MySQL - Video Tutorial in Urdu

Image
Following topics are covered in the tutorials: Connecting with database Understanding MySQL Driver - MySQL Connector/J Creating connection object from DriverManager class Creating Statement object Running Select query Creating ResultSet object Iterating the ResultSet Running update query Dunning delete query Running Insert query Understanding MySQL to Java data types mappings