19 February 2016

Factory Method Design Pattern in Java

The Factory Design Pattern is probably the most used design pattern in modern programming languages like Java.  Here we discuss about it and I will show you a demo.



A Factory Pattern or Factory Method Pattern says that just define an interface or abstract class for creating an object but let the subclasses decide which class to instantiate. It means Subclasses are responsible to create the instance of class.

This Pattern also known as Virtual Constructor.

What is the Intention?

  • Define an interface or abstract class for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  • Creates objects without exposing the instantiation logic to the client.
  • It promotes the loose-coupling by eliminating the need to bind application-specific classes into the code.
Factory Method is to creating objects as Template Method is to implementing an algorithm. A super class specifies all standard and generic behavior (using pure virtual "placeholders" for creation steps), and then delegates the creation details to subclasses that are supplied by the client.

Factory Method makes a design more customizable and only a little more complicated. Other design patterns require new classes, whereas Factory Method only requires a new operation.

People often use Factory Method as the standard way to create objects; but it isn't necessary if  the class that's instantiated never changes, or instantiation takes place in an operation that subclasses can easily override.

Factory Method is similar to Abstract Factory but without the emphasis on families.

Factory Methods are routinely specified by an architectural framework, and then implemented by the user of the framework.

Example:

First of all we create an abstract class and then we make some concrete classes which extends the abstract class.

Then we create an another class to get the object of abstract class.

Finally we will create main class in which do the work for us.(The business Logic Part I guess !!)

Here is the link of Example. Factory Pattern in Java

Output :


Subscribe for more updates on Java.

13 August 2014

Copyright- A strange thing to understand

     We live in an age of ever-expanding copyright law. The length of time that elapses before a creative work enters the public domain is now so long that many items published early last century are still protected by copyright.

      The Digital Millennium Copyright Act is regularly used to remove copyright infringing content from the Internet. In some cases the take-down is legitimate, but in other cases the DMCA is misused and things that are legitimately protected by "fair use" are taken down. Content creators can fight a take down, but doing so is usually a laborious process. Conversely, some content creators and consumers attempt to redefine or expand "fair use" to include any use they wish so they can use source materials without getting permission or complying with the law. But were things always the way they are now?

     No. They were not.

     How did we get to this point? To answer that question, I would like to direct you to a recent journal article by Meredith L. McGill, who is an associate professor of English at Rutgers University. McGill's article entitled "Copyright and Intellectual Property: The State of the Disciple" was published in the latest volume of the academic journal Book History, the professional journal of The Society for the History of Authorship, Reading and Publishing. The article is an overview of existing scholarship about the history of copyright and intellectual property. Despite the fact that it is a meta-history written for a specialized audience (scholars of book history), McGill's article serves as an excellent introduction for any reader to the changes that have taken place in copyright laws over the past few centuries.

     The first major section, "Copyright, Author's Rights, and the History of the Book," highlights the origin and development of both copyright law and authors' rights by examining the scholarly literature on these topics. Perhaps the key point to note is that copyright did not emerge at the same time as the introduction of printing. Copyright law as we know it began in the eighteen century with the British Statute of Anne (1710). Also worth noting is just how recently U.S. copyright law has changed into its current form. It is has only been a few decades since the U.S. Copyright Act of 1976 altered copyright law so that copyright was granted on creation instead of upon registration and greatly extended the length of time copyright protection lasts (a term of 28 years with one renewal became the life of the author plus 50 years). That act and several subsequent laws are what make U.S. copyright law what it is today.

     The next section, "The Place of the Law in British Publishing," examines British copyright law, beginning with the ways publishing worked before the Statute of Anne and continuing into modern times. McGill cites a wide variety of quality scholarship in this section, but the most interesting is her examination of Adrian John's Piracy: The Intellectual Property Wars from Gutenberg to Gates. She marks the publication of John's work as the point in which "[b]ook history and contemporary intellectual property discourse may be said finally to join forces." McGill's summary of Piracy connects John's approach to the rise of the copyleft movement, making it of particular interest to Opensource.com readers.

     Next McGill covers "Domestic and International Copyright in the United States" and looks at how copyright law developed in the United States of America. McGill spends some time discussing how originally (and for the first century of U.S. copyright law) copyright protection only applied to citizens and residents. Foreign works were not covered by copyright laws and could be published by American publishers without them having to pay the authors—though in some cases American publishers would pay foreign authors out of courtesy or so they could publish an "authorized edition." This section also examines the expansion of what is covered by copyright, and the changes that have taken place as copyright law expanded to cover photographs, sound recordings, film, television, and other things.
     
     Lastly, McGill covers topics in need of further study in a section entitled "Investment Properties." This section is much more useful to a book historian than it is to a general reader, but it still raises several points of interest. In particular is McGill's discussion of copyright outside the Anglo-American sphere. For example, she looks at scholarship relating to China in order to show how a country with a different intellectual heritage has a different take on intellectual property. She also covers scholarship relating to scientific works, religious texts, theatrical works, works that were considered too ephemeral to be covered by copyright, works considered too perverse to be granted copyright protection, and several other topics.

     McGill's article should be required reading for anyone interested in the history of copyright or in copyright reform. Understanding the past is crucial to changing the future, and McGill provides a great way to understand the past. The article itself is an excellent summary of the story so far, and her "Notes" section includes a large selection of interesting scholarly works for those who wish to dig deeper into the various topics covered in her article.

     Book History is, unfortunately, not an open access journal, but the current volume is freely available to anyone. You can download McGill's article and all the other articles from Book History Volume 16 from Project Muse. However, as soon as a new volume comes out (which is in the Fall), Volume 16 will no longer be freely available. At that point, you will need to have access to a library that subscribes to the journal if you want to read it. So, make sure to download the article as soon as possible if you want to add it to your "to read" pile.

Source: opensource.com

The full citation for Meredith L. McGill's article is:
McGill, Meredith L. "Copyright and Intellectual Property: The State of the Discipline." Book History 16, no. 1 (2013): 387–427. doi:10.1353/bh.2013.0010.

6 April 2014

Testing the Arduino Board

There will come a moment in your experimentation when nothing will be working and you will have to figure out how to fix it. Troubleshooting and debugging are ancient arts in which there are a few simple rules, but most of the results are obtained through a lot of work.

Suppose the program of blinking an LED on arduino in the last post is not working!! What should you do?? Let's figure out what to do?

Test the Board:
  • Plug your Arduino into a USB plug on your computer.
  • If the green light marked PWR turns on, this means that the computer is powering the board. If the LED seems very faint, something is wrong with the power: try a different USB cable and
    inspect the computer’s USB port and the Arduino’s USB plug to see whether there is any damage. If all else fails, try a different USB port on your computer or a different computer entirely.
  • If you have been using an external power supply and are using an old Arduino, make sure that the power supply is plugged in and that the jumper marked SV1 is connecting the two pins that are nearest to the external power supply connector.
  • If the Arduino is brand new, the yellow LED marked L will start blinking in a bit of a nervous pattern; this is the test program that was loaded at the factory to test the board.
  • If you have gone through all these steps successfully, then you can be confident that your Arduino is working correctly.
When you are having trouble with other sketches and need to confirm that the board is functioning, open the first “blink an LED” example in the Arduino IDE and upload it to the board. The on-board LED should blink in a regular pattern.

9 September 2013

Arduino Tutorials

Hello Friends, As we all know that Arduino is the open source electronics prototyping platform. Here are some of the tutorial for Arduino.
1. Blinking LED
Steps:
  • Double click on Arduino icon. ( You can download Arduino From www.arduino.cc)
  • Select File> New
  • Give the folder name Blink_LED and click OK.
  • Type the code as  given in pdf at end of this post in main window of Arduino IDE.
  • Now you have to verify this code(ctrl+R).
  • If your code is correct then press upload to I/O board button.( as shown in fig)
  • When you see done uploading at the bottom then you have completed correctly.
  • your LED will be blinking.
You can do many other tutorial as given in the below pdf file. For more tutorias go to www.arduino.cc

2 September 2013

Creation of matrix in matlab

As the name suggests MATLAB (Matrix Laboratory) , matrix is the vital part of MATLAB. so today i am going to tell you how to create different types of matrices in MATLAB.
Informally, the terms matrix and the array are often  used interchangeably. More precisely , a matrix is a two- dimensional rectangular  array of real or complex numbers that represents a linear transformation. The linear algebraic operations defined on matrices have found applications in a wide variety of technical fields.
MATLAB has dozens of functions that create different kinds of matrices. These commands you can try on your command window of MATLAB.
  1. A=magic(3)                   % creates random 3 by 3 matrix
  2. B=pascal(3)                  % creates symmetric matrix
  3. C=fix(10*rand(3,2))      % creates 3 by 2 rectangular matrix of random integers
  4. x=[7;8;9]                      % produce a column vector
  5. y=[4 5 -6]                     % produce a row vector
  6. z=2                               % produce a scalar
so from this code you can try and make your own matrix in MATLAB.

2 August 2013

Power Supply

Every person who is related with Electronics field must know about the power supply used in Electronics circuits. Today i m going to tell you about the power supply used in Electronics circuits.

First of all we all know that in our house we have 230V power supply specially in india. But this much of power supply damages the electronics circuit which we use for our projects and research purpose. So what should we do to get power supply of 5V or 12V?? Here it is the circuit which converts 230V into 5V or 12V.


To make this circuit you require Transformer, two diodes, a Voltage regulator IC 7805, two capacitors.
I hope this will help you in your projects or study.

17 July 2013

Reference book list for ece in GATE

Here I am going to tell you the reference books which contain the concepts of Electronics & Communication Engineering for the preparation of GATE...




  • Engineering Mathematics:
          1) Higher Engineering Mathematics by B.S.Grewal
                   a) Solutions to differential equations
                     b) Complex analysis
                       c) Vector calculus
                    2) Advanced Engineering Mathematics by Erwyn Kreyszig
                        a) Differential equations: Euler-Cauchy, existence and uniqueness of solutions:        Wronsian and  homogeneous linear ODEs
                             b) Vector calculus: Change of variables in surface integrals
                          3) Calculus (Differential and Integral) by Shanti Narayan
                            4) Probability, Random Variables and Stochastic Processes by Papoulis, Pillai

                  • Digital Electronics:
                                Morris Mano - Digital Logic Computer Design

                  • Network Analysis :
                                Hayt and Kemmerly - Engineering Circuit Analysis

                  • Signals and Systems:
                               1) Oppenheim, Willsky - Signals and Systems
                                 2) Oppenheim, Schafer - Discrete-Time Signal Processing (DFT and FFT)

                    • Control Theory:
                                 1) Katsushiko Ogata - Modern Control Engineering

                                 2) Norman Nise - Control Systems Engineering (Stability Analysis)

                                 3) Schaum's Outline of Feedback and Control Systems (Polar and Nyquist plots)

                    • Electro Magnetic Theory, Transmission Lines, Waveguides and Antennas:
                                 1) Sadiku - Elements of Electromagnetics
                                   2) Jordan and Balanis - Electromagnetic Waves and Radiating Systems
                                     3) Harish and Sachidananda - Antennas and Wave Propagation

                        • Communication Engineering:
                                    1) Simon Haykin - Communication Systems

                                    2) B.P. Lathi - Modern Analog and Digital Communication

                        • Analog Circuits:
                                   1) Robert Boylestad - Electronic Devices and Circuit Theory
                                     2) Sedra and Smith - Microelectronic Circuits

                          • Electronic Devices:
                                     1) Streetman, Banerjee - "Solid State Electronic Devices"

                          I hope this list of books will help you in the preparation of GATE. Best of luck guys!!!!!

                          Factory Method Design Pattern in Java

                          The Factory Design Pattern is probably the most used design pattern in modern programming languages like Java.  Here we discuss about it an...