How to implement unstable behavior / requirement

The customer, as we know, is always right even when he returns on his steps, and he forces you to review / rewrite a behavior for a component that seemed clear.

But the worst has not yet arrived, because the user can ask to change that requirement again, or worse, put things back as they were before.

Fortunately, Object Orientation comes to your aid with one of the most important design principles.

“Identify aspects of application that vary and separate them from what stays the same.”

If you have a feature of your program that

  • your client asks you to change several times
  • or simply that it can have different behaviors based on different inputs

then it is necessary to extract it from the main context and create one or more components that implement these different versions / behaviors.
Don’t be fooled to use the inheritance! In this case, in fact, inheritance cannot help you because there is the risk of having unwanted behavior performed.

Even the interfaces may not be sufficient because it forces you to write methods that are not used or to write the same method several times, duplicating the code.

Create a set of classes for each feature that tends to vary, where each class represents a possible behavior
Of course this set of classes implements the same interface.

Furthermore, following the principle
“Program with Interface and not with implementation”

to implement “unstable requirement” you will refer this interface in the main system.

In this way your client can change his mind whenever he wants, and you will be ready to please him and, perhaps, become his best friend or psychologist …

React Native – The Practical Guide

How to use React Native and React knowledge to take web development skills and build native iOS and Android Apps

  • Build native mobile apps with JavaScript and React
  • Dive deeper into React Native
  • Develop cross-platform (iOS and Android) mobile apps without knowing Swift, ObjectiveC or Java/ Android
How to integrate young framework like React in old web pages

In these days I’m trying to improve the user experience of an old JSP page. So I thought of injecting into it some custom components of the framework react.

Integrate a basic React app inside an existing web page, like for example an HTML or JSP or PHP page, is very very simple and, most important thing, it does not require a build and an import of tons of prebuild files.

Below an example of how to do this integration inside a generic html page.

<script crossorigin src=""></script>
<script crossorigin src=""></script>
<script src=""></script>
<script src=""></script>
<script type="text/babel" src="/js/app.js"></script>

<div id="react-content" />

<script type="text/babel">
ReactDOM.render(<CustomApp />, document.getElementById('react-content'));

And nothing special in app.js file than a classic CustomApp class react component!

The possibility of using React directly in existing web pages, without big frills and various builds, is really very convenient.
I don’t know if Angular can also be used in the same way. I’ll try in the next few days.