Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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.
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.
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.
7. DON’T WRITE CODE THAT ISN’T NEEDED:-
Do the simplest thing possible. Don’t 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.
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.
It wasn’t going to be ten until I got to 8 and then thought no one writes 8 tips, let us add two more on.
It isn’t really a list but it’s sort of aims and mental notes I try to tell myself when writing code. They are
OOP AND CODE REDUSE
The Code Reuse Continuum
CODE REUSE
Code reuse is the use of existing software to deliver functionality. The following are common types of code reuse.
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
5.SERVICES
Services reuse both the code and the operational aspects of a technology. For example, one team can operate a
market data service for a bank as opposed to having 50 systems and applications that connect to market data
feeds.
7.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.
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
Not 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.
CONCLUSION
Don’t give up on your efforts to write reusable code! This tip outlines three ways you can
modify your existing code to increase its reusability.
https://www.loginworks.com/blogs/reuse-code-object-oriented-programming/
Thank You For Watching
https://www.loginworks.com