Title: HOW TO REUSE CODE IN OBJECT ORIENTED PROGRAMMING
1 Welcome to Loginworks Softwares
2HOW TO REUSE CODE IN OBJECT ORIENTED PROGRAMMING
- REUSE GOOD IDEAS
- To save development time, code reuse is often
seen as a method of cutting project costs and
shortening time to market, but it has several
benefits of saving time.This study provides an
arguably much needed real, industrially-based
experiment regarding brainstorming. The results
and observations suggest that having a guided
approach to sourcing creative stimuli is very
beneficial. However, the Sweeper tool using
internally sourced stimuli provides a method that
is useful and more a practical alternative, as it
is based firmly in the domain of activity.For
information technology-intensive businesses the
code is expensive and time-consuming to develop
and code to reuse is considered a fundamental
productivity strategy.
3TIPS ON WRITING REUSABLE CODE
- 1. KEEP THE CODE DRY. DRY MEANS DONT REPEAT
YOURSELF - This is one of the main changes I have tried to
bring in. Always try to eradicate duplication and
if you find any then move remove the duplication
to a relevant place. Sometimes this has to lead
me to create Static Helper classes or sometimes
move it to the class it makes the most sense to
have it. - To save development time code reuse is often seen
as a method of cutting project costs and
shortening time to market, but it has several
benefits of saving time. - 2. MAKE A CLASS/METHOD DO JUST ONE THING-
- This is along the lines of the advice of giving
the class only one reason to change. This often
means creating methods that other methods use but
this helps to make the methods/classes simple and
less coupled.
43. WRITE UNIT TESTS FOR YOUR CLASSES AND MAKE IT
EASY TO TEST CLASSES-
Writing code that is easy to test is decoupled.
If you write code and are thinking about writing
a unit test for it then you tend to split up the
code into smaller testable chunks.
4. REMOVE LOGIC OR MAIN CODE AWAY FROM ANY
FRAMEWORK CODE-
Following the rules above will help this.
5. TRY TO THINK MORE ABSTRACTLY AND USE
INTERFACES AND ABSTRACT CLASSES-
Try to hide dependencies of code behind a more
Generic interface/abstract class. The benefit
this gives the code is it creates a flexible
point in the code where you can then hide future
changes behind.
6. CODE FOR AN EXTENSION.
This is particularly true with the above point.
If you write code that uses interfaces then you
can extend that interface at a later point.
5 7. DONT WRITE CODE THAT ISNT NEEDED-
Do the simplest thing possible. Dont waste your
time adding methods and classes that might be
used in the future. Keep the code simple and
focused on what you are trying to deliver. I
think I read/heard Josh Bloch say once that if
in doubt, leave it out. Basically, who wants to
write code that no one (including yourself) is
going to use again.
8. TRY TO REDUCE COUPLING-
When writing code thinks about the links and
coupling the code is creating, does it need to be
linked to those other classes.
9. BE MORE MODULAR-
OOP is the standard approach to software
engineering. when solving a problem, must
identify the objects involved.
10. WRITE YOUR CODE IS AN EXTERNAL API-
Imagine the code you are writing is a
self-contained component.
It wasnt going to be ten until I got to 8 and
then thought no one writes 8 tips, let us add two
more on. It isnt really a list but its sort of
aims and mental notes I try to tell myself when
writing code. They are more small bits of code I
have written recently that has helped. I would
like to hear peoples comments and especially
their tips on writing reusable code.
6OOP AND CODE REDUSE
7The Code Reuse Continuum
8 CODE REUSE
Code reuse is the use of existing software to
deliver functionality. The following are common
types of code reuse.
1.OFF THE SHELF
Using commercial or non-commercial products that
exist as opposed to reinventing them.
2.EXTENSION
Extending your current systems, applications,
services, and libraries as opposed to doing
something completely new.
3.COMPONENTS
Designing systems and applications to maximize
reuse by dividing functionality into useful
components that hide complexity behind an
interface.
4.LIBRARIES
97.CUT PASTE
It is common for developers to copy code with
which they are familiar and change it to be
something new.
8.FORKING
Officially taking the code and changing it to be
something new by creating a fork in a version
control system.
THE BENEFITS AND COSTS OF CODE REUSE
It allows multiple developers to integrate IP
into their code using similar styles and
programming conventions.
This saves time, improves the features in your
program, and generally makes for more
cost-effective programming.
Reusability is an important issue in software
engineering for at least two major reasons.
The traditional approach tends to tread the
mentioned concepts as equal, which creates
some illusions in those who did not grasp the
main idea.
Forgot to address one thing. Overriding is
really an OOP concept. So-called overloading is
not. The second concept does not deserve a
separate name itself. This is one of the worst
and confusing terms which misleads too many
people in the whole industry.
10Not using OOP using a pure OOP language may mean
different approaches, but is possible when one
uses classes formally, not leveraging OOP power
in any way. How? One can use only static methods,
never virtual ones, not even instance non-virtual
methods (in some languages, static methods can be
abstract/virtual, quite naturally).
There is no any late binding and/or polymorphism
without, say, encapsulation and inheritance.
A compiler can distinguish them by profile
inferred from the calling code.
Dont Use Generic Code Instead use small
,composable components.
Making Software to generic can make it too
complicated to use.
CONCLUSION
Dont give up on your efforts to write reusable
code! This tip outlines three ways you can modify
your existing code to increase its
reusability.Connect with source url-
https//www.loginworks.com/blogs/reuse-code-objec
t-oriented-programming/
11 Thank You For Watching
Connect with This For More
Inf
https//www.loginworks.co
m
Call us
1-434-608-0184