Credits : Theserverside

Software is everywhere, but the process to create a new software product can be complicated and challenging. That’s why software development best practices are important and can help reduce costs and speed up processes.

Without goals, a software project doesn’t have direction. Projects should start with a clear definition of the planned software’s goals, a discussion of those goals with stakeholders and an evaluation of expectations and risks. Simultaneously, you should be ready for various challenges that can come up, and implement strategies to keep the development process on course.

Best practices aren’t always a revelation of thought. Sometimes they are obvious. But as obvious as they might be, they are often overlooked, and developers need to be reminded of them. These software development best practices are obligatory for all software development projects.

Top five software development best practices

  1. Simplicity

Any software should be created in the most efficient way without unnecessary complexity. Simpler answers are usually more correct, and this thought perfectly meets the needs of the development process. Simplicity coincides with minor coding principles such as Don’t Repeat Yourself (DRY) or You Aren’t Gonna Need It (YAGNI).

  1. Coherence

Teamwork is vital for big projects and it’s impossible without a high level of consistency. Code coherence stands for the creation and adherence to a common writing style for all employees who develop software. This will allow managers or other coders to tell who the author of a given fragment is. Yes, when the whole code has the same style, it’s coherent.

Consistency helps a lot because colleagues will be able to test, edit or continue the work of each other. Vice versa, inharmonious projects can confuse your team and slow down the development process. Here are some tools that will help you enforce a single style:

  • Editorconfig: A system for the unification of code written with different IDEs,
  • ESLint: A highly customizable linter based on node.js,
  • JSCS: A linter and formatting tool for JavaScript,
  • HTML Tidy: Another linter for HTML which also finds errors and;
  • Stylelint: A linter for CSS with various plugins.
  1. Testing

Testing is essential for any product and on any stage. From the very first test run to the final evaluations, you should always test the product.

Thanks to modern approaches and the rise of machine learning, engineers have access to powerful tools such as automated algorithms to run millions of tests each second. Strategic thinking helps when you have to choose a testing type: functional, performance, integration or unit. If you choose the tools and testing types carefully, you can find a host of bugs and others issues that can ideally be fleshed out before you deploy your product. But remember not to only focus on test-driven development, remember about users and their needs.

  1. Maintenance

Unlike physical entities, the software has the potential to be immortal. Nevertheless, this would only be possible with good maintenance including regular updates, more tests and analysis. You’ve probably seen a warning before about an application that isn’t compatible you’re your device. Elaborate maintenance can get rid of these alerts and keep apps compatible with any hardware.

This principle is a bit controversial as not all teams or developers want to waste time on product compatibility with everything. However, you should focus on maintaining fresh code to allow your software to work on new devices. Thus, your product will meet the needs of more customers and help old applications to remain useful.

  1. Analysis

Apart from the pre-launch evaluation conducted by QA engineers and dedicated software developers, let me suggest you focus on performance analysis post-launch. Even the most elaborate code that results in a seemingly perfect match with your client isn’t guaranteed to work properly. There are a number of factors that can affect these results. Ideally, you’d like to have an analytics department to evaluate your numbers, but outsourced specialists always will work.

Methodologies and best practices

Apart from the aforementioned approaches, there are some other software development best practices to consider. Minor principles such as these can help play a role in a successful deployment:

  • Agile: This approach can help optimize your work. It is based on several development iterations that involve constant testing and result evaluation,
  • Repositories: Platforms such as Git are helpful to track versions, move back to previous iterations, work synchronization, and merging,
  • Accuracy over speed: Focus on correct code instead of fast code. Later it will be easier to speed up processes than rewrite everything and;
  • Experience sharing: Consider exchanging ideas and results with other developers to get external reviews if your project isn’t confidential.

Finally, let me propose a bit paradoxical statement: you don’t have to blindly follow best practices all the time. Time-proven ideas work fine for traditional processes when developers want to create common software without unique features.

But game-changing apps or innovative projects require fresh thinking. Surely, these software development best practices are fairly obvious and cover the most basic practices, but it’s better to find or build a software development team with a perfect balance between best market approaches and new ideas.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : Androidauthority

While HTML lays the groundwork for your website or app, PHP takes it to the next level. Despite how powerful of a coding language it is, many web developers don’t know its full potential.

That’s where the Ultimate PHP Training Bundle comes in. This beginner-to-advanced course features 90 different lectures and over 12 hours of content covering all things PHP.

Build seamless, interactive sites.

Even if you’re just starting out, this course will have you building seamless, interactive sites before you know it. You’ll start with the syntax, development environment, and basic commands. Then, you’ll move on to more advanced topics like database storage, web interfacing, debugging, basic SQL language commands and application logging.

When you think you’ve got a grasp on it, there are quizzes to help you test your PHP knowledge.

Dynamic websites begin with PHP. Get this $97 Ultimate PHP Training Bundle for just $19 (80 percent off) today and start building.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : Hub.packtpub

Joe Watkins, a PHP developer, shared that PHP 8 will support the Just-in-Time (JIT) compilation. This decision was the result of voting among the PHP core developers for supporting JIT in PHP 8 and also in PHP 7.4 as an experimental feature.

If you don’t know what JIT is, it is a compiling strategy in which a program is compiled on the fly into a form that’s usually faster, typically the host CPU’s native instruction set. To do this the JIT compiler has access to dynamic runtime information whereas a standard compiler doesn’t.

How PHP programs are compiled?

PHP comes with a virtual machine named the Zend VM. The human-readable scripts are compiled into instructions, which are called opcodes that are understandable to the virtual machine. Opcodes are low-level, and hence faster to translate to machine code as compared to the original PHP code. This stage of execution is called compile time. These opcodes are then executed by the Zend VM in the runtime stage.

JIT is being implemented as an almost independent part of OPcache, an extension to cache the opcodes so that compilation happens only when it is required. In PHP, JIT will treat the instructions generated for the Zend VM as the intermediate representation. It will then generate an architecture dependent machine code so that the host of your code is no longer the Zend VM, but the CPU directly.

Why JIT is introduced in PHP?

PHP hits the brick wall

Many improvements have been done to PHP since its 7.0 version including optimizations for HashTable, specializations in the Zend VM for certain opcodes, specializations in the compiler for certain sequences, and many more. After so many improvements, now PHP has reached the extent of its ability to be improved any further.

PHP for non-Web scenarios

Adding support for JIT in PHP will allow its use in scenarios for which it is not even considered today, i.e., in other non-web, CPU-intensive scenarios, where the performance benefits will be very substantial.

Faster innovation and more secure implementations

With JIT support, the team will be able to develop built-in functions in PHP instead of C without any huge performance penalty. This will make PHP less susceptible to memory management, overflows, and other similar issues associated with C-based development.

We can expect the release of PHP 7.4 later this year, which will debut JIT in PHP.  Though there is no official announcement about the release schedule of PHP 8, many are speculating its release in late 2021.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : mysanantonio

To create a killer business, you need a killer business plan. A compelling business plan not only piques the interest of investors, but it’s also a must-have tool for understanding the nuts and bolts of how your company will get from point A to point B. Your plan will give you a bird’s eye view of how your business may perform in the marketplace, how many team members you’ll need, your must-have supplies and how much you’ll need to spend on fundraising and advertising.

You might be able to craft a persuasive business plan using Microsoft Word or Google Docs, but it’ll be harder to grab your reader’s attention without an eye-catching format. If you don’t know Photoshop from PowerPoint and you can’t afford to hire a graphic designer, Bizplan Premium can help you construct a gorgeous plan through its user-friendly interface.

Bizplan Premium is a step-by-step business builder that puts all of your thoughts in a cohesive, collaboration-friendly format. The drag-and-drop templates help you pull off professional-level graphic design in minutes. Bizplan uses self-paced progress tracking, which breaks down major projects into bite-sized pieces and lets you skip around from financial forecasts to market predictions without losing your place.

If your important financial data lives in other programs, like Xero or QuickBooks, Bizplan Premium can import it in minutes. This will help you perform team salary forecasts and break down revenue vs. expenses with ease. There are also plenty of easy-to-use financial templates, so your data will have a professional edge when you present it to interested investors.

Some of Bizplan’s most helpful features are its collaboration options. You can share your plan online and collaborate with your whole team. If someone needs to jump in with feedback, they can start a group of threaded comments in any section across your entire plan — it’s great for promoting conversation across multiple departments. You can also share it with investors and stakeholders, who can leave their comments on your plan in real time.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

credits : Nanowerk


(Nanowerk News) New software lets users design science-fiction-like materials with the same efficiency that architects draft building plans.
Sandia National Laboratories has created the first inverse-design software for optical metamaterials — meaning users start by describing the result they want, and the software fills in the steps to get there. The modern design approach takes guesswork out of engineering as-yet theoretical technologies like ultracompact, high-performance cameras and cloaking armor that could make wearers invisible to detection.
Sandia uses the design aid, called Mirage, in its research and development programs and released a test version to select collaborators last year. Now, researchers working on government metamaterial projects can request a license at no cost.
Man-made, optical metamaterials have been touted for more than a decade for their ability to manipulate light in extraordinary ways. In theory, satellite imaging and interstellar telescopes could be dramatically smaller with metamaterial lenses one hundred times thinner than conventional ones. Or, the technology could someday lead to cloaking materials that deflect light around them, rendering objects impossible to see.
Mirage simplifies and automates the design process for materials that would be necessary for those technologies.
Mirage takes guesswork out of design
The field of optical metamaterials has so far struggled to deliver on all its perceived promise of revolutionizing optics. One difficulty for engineers has been that metamaterials are made of tiny building blocks, called meta-atoms, which can be designed in countless variations. A certain shape, collectively, might bend light. Change that shape, the size, the spacing or the material and that might amplify the effect or diminish it or cause something entirely different to happen, like twist the light one direction or another or change its intensity or color.
“Predicting what the bulk ‘homogenized’ properties will be has been very hard to determine until now,” said Mike Fiddy, a program manager in the Defense Advanced Research Projects Agency, or DARPA, which funded the software’s development.
Other software can simulate what meta-atoms will do to light, but that only allows researchers to use intuition to experiment with different designs until they stumble upon or tediously work out the behavior they want.
Despite the challenge, some researchers have had success creating imaginative metamaterial devices. Sandia invented a device that converts heat to electricity, potentially for more fuel-efficient engines, and a light-mixing technology that could lead to a new, changeable, multicolored light source, which could accelerate all kinds of research from archeology to biomedicine.
But on the whole, said Sandia scientist Ihab El-Kady, the metamaterial enterprise has needed a boost.
“We cannot possibly solve this problem by trial and error,” said El-Kady, who conceived Mirage. “Instead, we could do the opposite. We could say: ‘Here is the behavior I want. Now tell me what the metamaterial looks like.’”
No tool used this inverse-design approach. So, El-Kady and his team at Sandia’s National Security Photonics Center built one.
User-friendly instructions to exploit 100-plus templates
Mirage lets users start by telling it the optical property they want — how their metamaterial needs to interact with light — and their starting materials. Mirage generates designs that match those criteria from a library of more than 100 templates. Or, users can draw their own designs, and the program will check them for errors.
“A more systematic approach for designing metamaterials should greatly accelerate their adoption in various application areas,” eliminating more commonly used, intuition-based approaches, Fiddy said.
DARPA featured Mirage as a premier technology at the agency’s 60th Anniversary Symposium in Fort Washington, Maryland, showcasing its far-reaching uses.
“Mirage is an all-in-one tool,” El-Kady said. “Not only does it tell you what the metamaterial looks like, it allows you to explore various configurations, simulate the system, validate the chosen behavior, visualize its response and optimize its functionality within your fabrication constraints.”
Software refines powerful ideas
On top of that, said Sandia senior scientist Igal Brener, who uses the software in his metamaterial research, Mirage is useful because it includes algorithms that help researchers get the best performance from their inventions.
Brener’s team previously created a material that can mix two lasers to produce 11 colors at once, including infrared and ultraviolet light. Potentially, this technology could be developed into tunable lasers that replace single-color ones.
But some of those colors are too dim to be useful, so he’s exploring ways to brighten the output. Other software packages Brener has used include simple optimization algorithms. However, to use more advanced algorithms he must supplement those packages with his own coding. Not so with Mirage.
“Optimization techniques come in many different flavors,” he said. “Mirage is the only software package I know of that has the complex optimization techniques I need built in.”
If the initial launch is successful, Sandia plans to develop a second version of Mirage, tentatively called Mirage Elite, that would introduce a surge forward in optimization by automatically morphing meta-atoms into bizarre and outlandish shapes in the hunt for undiscovered behaviors.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : Searchsecurity.techtarget

 

A zero-day in jQuery File Upload could affect thousands of projects because the jQuery plugin vulnerability has existed for eight years and actively exploited for at least three years.

A zero-day flaw in the popular jQuery File Upload plugin that could affect thousands of projects has been actively exploited for at least three years.

After Cashdollar reported the jQuery plugin vulnerability to its creator, Sebastian Tschan, the German developer who goes by the nym “Blueimp,” the two worked together and discovered the issue was caused by a change in the Apache HTTPD server. The change was made in Apacheversion 2.3.9 — made five days before release of the first version of jQuery File Upload in 2010 — and it disabled support for .htaccess web server configuration in order to prevent security features from being overridden. Unfortunately, Tschan’s plugin relied on .htaccess to implement security controls.

However, Cashdollar said in his report that “Apache had good reasons to disable .htaccess, but their changes left some developers and their projects open to attack, especially if they relied on .htaccess as a security function.”

“The internet relies on many security controls every day in order to keep our systems, data, and transactions safe and secure,” Cashdollar wrote. “If one of these controls suddenly doesn’t exist it may put security at risk unknowingly to the users and software developers relying on them.”

The issue was in the source code of the jQuery File Upload plugin, originally developed by Tschan, so the vulnerability could affect many other projects.

According to GitHub, jQuery File Upload is the most starred — meaning users mark it in order to signal interest and support — jQuery plugin and also the most forked. Cashdollar said the plugin has been forked more than 7,800 times and could have been built in to thousands of other projects, making it difficult to determine how widespread the jQuery plugin vulnerability could be.

“Unfortunately, there is no way to accurately determine how many of the projects forked from jQuery File Upload are being properly maintained and applying changes as they happen in the master project,” Cashdollar wrote. “Also, there is no way to determine where the forked projects are being used in production environments if they’re being used in such a way. Moreover, older versions of the project were also vulnerable to the file upload issue, going back to 2010.”

Although Cashdollar has credit for discovering the jQuery plugin vulnerability (CVE-2018-9206), it seems to have been an open secret as YouTube videos going back to 2015 show how to exploit the flaw.

“I suspected this vulnerability hadn’t gone unnoticed and a quick Google search confirmed that other projects that used this code or possibly code derived from it were vulnerable,” Cashdollar wrote. “There are a few Youtube (sic) videos demonstrating the attack for similar software packages.”

Tschan patched the plugin in version 9.22.1, but because of the number of forks and other products using the plugin, it’s unclear how many other vulnerable programs still exist.

 

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

 

Credits : Sdtimes

 

2018 was a big year for Java because of the changes to the language’s release schedule and the transfer of Java EE to the Eclipse Foundation. Last year, Oracle announced that it would be releasing major versions of Java twice per year, and Java 10 was the first release in that new schedule.

Java 10 was released in March and included features such as extending type inferences to local variable declarations, GC parallelization, optimized startup time, and the ability to use Graal as an experimental JIT compiler on Linux/x64.

Java 11 was released in September and was a Long Term Support (LTS) release, which means that it will be supported by Oracle via security and bug-fixing updates until at least 2026.

Sometime between the release of Java 10 and Java 11, the JVM Ecosystem Survey Report revealed that Java 8 was still the most widely used version of Java. The report found that 79 percent of developers use Java 8, four percent use Java 9, and four percent use Java 10.

In February, Java EE was renamed to Jakarta EE after being moved to the Eclipse Foundation from Oracle. The name is a reference to the Jakarta Project, which was an early Apache open-source project. A new specification process called the Eclipse Foundation Specification Process was also created. Other renamed Java projects include Glassfish, which is now Eclipse Glassfish, and Oracle development management, which is now Eclipse Enterprise for Java Project Management Committee.

The Eclipse Foundation also added 16 new members to support the growth of the Jakarta EE and IoT communities.

In March, Oracle split off JavaFX into its own module. It was previously part of the JDK, and will continue to be supported as part of JDK 8 until at least 2022, but starting with Java 11 it was available as its own module. Oracle revealed that it would work with third parties to make it easier to maintain JavaFX as an open-source module.

Other cuts made by Oracle include removing support for Applets in 2019 and removing Java Web Start starting with Java 11. According to the company, Java Web Start will be supported in Java 8 until 2025, and products with Web Start dependencies will be supported on a to-be-determined timeline.

In June, the Eclipse Foundation released the latest version of the Eclipse IDE. Eclipse Photon expanded on polyglot capabilities. New features include C# editing and debugging capabilities, support for Java 10 and Java EE 8, dark theme improvements, and support for building, debugging, running, and packaging Rust apps.

The next month, Google released Jib, which is a method that Java developers can use to containerize applications. The reasoning behind creating Jib was that Java developers are often not container experts, making it difficult to containerize their apps.

Amazon also released a no-cost distribution of OpenJDK in an effort to make sure that Java is available for free to its users in the long term. Amazon Corretto is available with long-term support, and Amazon will continue making performance enhancements and security fixes.

 

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : Mybroadband

 

According to the Tiobe Index for January 2019, Java, C, and Python remain the most popular programming languages in the world.

Other popular languages include C++ and Visual Basic, all ranked highly on the index.

While Python gained popularity significantly over the past year, Java remains the most popular language.

It has dominated the rankings for years, and still shows high year-over-year growth, meaning it is not going anywhere for now.

There are multiple reasons for the extended popularity of this programming language, from its ease of use and capability to its widespread adoption and development.

Powerful and widely adopted

Many developers learn Java as one of their first programming languages, with its relatively simple syntax making for easier reading and understanding of functionality.

The language is also object-oriented and has a useful API which provides a lot of easy-to-use features.

While these make for a powerful and accessible programming language, the popularity of Java is the direct result of its adoption across platforms and its community investment.

Oracle has made Java available for free to all developers, and this has cultivated a strong community which produces a large collection of open-source libraries.

Perhaps most importantly, Java can run independently on the Java Virtual Machine – making it ideal for web programming and cross-platform applications.

Java developers can create applications for desktops, mobile, online platforms, and more, thanks to the language’s versatility.

The programming language currently has a variety of uses, and is used to build everything from Google docs to mobile games. Most commonly it is a tool to make small application models for use in web environments like ecommerce websites or financial trading platforms.

A number of useful software platforms are also created using Java, including Netbeans, Eclipse, and IntelliJ.

While it can be used to build impressive video games like Minecraft, it can also be used in an embedded environment as any system only needs 130KB of RAM to use Java technology.

The versatile programming language has also become the default for scientific applications.

The programming language is taught at universities and various other educational institutions worldwide, and is also available as a course from massive online open course (MOOC) platforms, including UdemyEdX, and Coursera.

Kotlin

Java is not without its competitors though, even though they do not appear in the top 10 rankings for popularity of programming languages.

While it does not appear on the top 10 list, Tiobe predicts that the programming language Kotlin will enter the top 20 list this year due to its rapidly-growing popularity.

Kotlin is designed to fully integrate with Java and the Java Virtual Machine, but offers more concise syntax and the option to compile to JavaScript.

It also fixes a number of issues which Java suffers from. For example, its null reference is controlled by the type system, arrays in Kotlin are invariant, it has proper function types, and does not have checked exceptions.

Google also officially supports Kotlin for mobile development on Android, and the language is included as an alternative to Java in Android Studio.

Kotlin is currently ranked at 31 on the Tiobe Index, but it is expected to soar up the rankings over time.

However, it still has a long way to go before it takes on Java for the title of most popular programming language in the world.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : Theserverside

 

Follow best practices for Java method design, and don’t allow one public class to call another. If you skipped this step, be prepared to pay the consequences.

While it seems so basic that it wouldn’t require a mention, there’s a basic and often violated software design principle pertaining to Java method modifiers that is in need of explanation.

A public method should never be called by another public method within the same class hierarchy. It should only be called by other classes via the classes’ public interface.

Class calls might not be the first and foremost software programming design principle, but it seems to be the one that I see broken most often. Fast-paced environments require a developer to get things done as quickly as possible and result in this principle often being overlooked for speed instead of clarity. As a result, when a use case pops up later on and requires the same public method from another class, we can run into problems. Another issue that can arise is that it becomes more difficult for a developer to refactor classes to a better design.

You can quickly and easily correct this Java method modifier issue based on how soon you can refactor. Then, it just comes down to which method you want to use.

Let’s explore two options on how to fix this issue and diagnose the pros and cons of each selection.

Java method modifiers example

To demonstrate your options as simply as possible, let’s start with a simple code example. I will use Spring Framework with @Transactional to demonstrate why a public method that calls another public method in the same class can create such a big problem. @Transactional is how Spring will add transactions to your code via proxies. These proxies will play a major role in how this call method issue will arise. In this code example, the OrderService interface’s saveOrder method brings up the main problem.

public interface OrderService {

public Order findOrder(long id);

public Order saveOrder(Order order);

public void updateCustomersOrdersAsShipped(long custId);

}

 

@Service

@Transactional

public class OrderServiceImpl implements OrderService {

 

private OrderRepository orderRepository;

 

@Autowired

public OrderServiceImpl(OrderRepository orderRepository) {

this.orderRepository = orderRepository;

}

 

@Override

public Order findOrder(long id) {

return orderRepository.findOne(id);

}

 

@Transactional(propagation=Propagation.REQUIRES_NEW)

@Override

public Order saveOrder(Order order) {

return  orderRepository.save(order);

}

 

@Override

public void updateCustomerOrdersAsShipped(long custId) {

List<Order> ordersForCustomer = orderRepository.findAllOrdersForCustomer(custId);

for (Order customerOrder: ordersForCustomer) {

boolean isReadyForShipment = validateOrderReadyForShipment(customerOrder);

customerOrder.setShipDate(new LocalDate());

//

Here, we now have a public method calling another public method within the same class:

this.saveOrder(customerOrder);

}

}

 

private boolean validateOrderReadyForShipment(Order order) {

boolean readyForShipment = true;

if (order.getReadyForShipment != null) {

readyForShipment = false;

}

return readyForShipment;

}

}

You will notice that we have updateCustomerOrderAsShipped — a public method in the interface or class — making a call to another public method saveOrder() in the same class. This can be problematic for a few reasons. The saveOrder method wants to have a brand new transaction created every time it gets called. However, because Spring adds transactionality via aspect-oriented programming proxies, the call from updateCustomerOrderAsShipped won’t create a new transaction. Instead, it will just participate in the already existing transaction because the call originates from inside the same class.

Imagine if you flew to Hawaii and received a lei. But once you’re in Hawaii, you can’t get another lei unless you leave the state and come back.

Fix the public method problem

There are a couple approaches to consider how to rectify the Java method modifier misuse issue.

A developer can move the shared code into a private method that both public methods call or move one of the public methods into a different class and let one class call the other.

But which one is the better choice to create transaction demarcation? The first choice still needs a call to the first public method to start a transaction and the next call would be to the second public method to start another new transaction. A developer must find a way to get outside the Spring-created proxy, and that can’t happen between a call within the same class. The only way this can occur is if the two methods are in two different classes and both get their own proxy. Also, one class will need to call the other and then go through the proxy of the called class.

Essentially, the first public method gets called from outside that class and starts a new transaction. Then, inside that class, it calls to another class through its proxy and creates the new REQUIRES_NEW transaction that we expected. I will create a new interface called CreateOrderService.

public interface CreateOrderService {

public Order saveOrder(Order order);

}

And an implementation public class CreateOrderServiceImpl implementsCreateOrderService:

{

private OrderRepository orderRepository;

 

@Autowired

public CreateOrderServiceImpl(OrderRepository orderRepository) {

this.orderRepository = orderRepository;

}

 

@Transactional(propagation=Propagation.REQUIRES_NEW)

@Override

public Order saveOrder(Order order) {

return  orderRepository.save(order);

}

}

With this new interface and class, OrderServiceImpl will now look like this:

public interface OrderService {

public Order findOrder(long id);

public void updateCustomersOrdersAsShipped(long custId);

}

 

@Service

@Transactional

public class OrderServiceImpl implements OrderService {

 

private CreateOrderService createOrderService;

 

private OrderRepository orderRepository;

 

@Autowired

public OrderServiceImpl(OrderRepository orderRepository, CreateOrderService createOrderService) {

this.orderRepository = orderRepository;

this.createOrderService = createOrderService;

}

 

@Override

public Order findOrder(long id) {

return orderRepository.findOne(id);

}

 

@Override

public void updateCustomerOrdersAsShipped(long custId) {

List<Order> ordersForCustomer = orderRepository.findAllOrdersForCustomer(custId);

for (Order customerOrder: ordersForCustomer) {

boolean isReadyForShipment = validateOrderReadyForShipment(customerOrder);

customerOrder.setShipDate(new LocalDate());

//

Here, we now have a public method calling another public method within the same class:

        createOrderService.saveOrder(customerOrder);

}

}

 

private boolean validateOrderReadyForShipment(Order order) {

boolean readyForShipment = true;

if (order.getReadyForShipment != null) {

readyForShipment = false;

}

return readyForShipment;

}

}

What are some tradeoffs with the two-class approach?

The biggest issue I’ve come across when addressing the Java method modifier issue focuses on application complexity with circular references among classes. For example, Class A references Class B, which references Class C, which, in turn, references Class A. As a result, a developer will need to untangle the circular references as Spring makes proxies and determine which class needs to be created first to properly set up the links. Other potential tradeoffs include extra classes in code bases and determining which methods need to be moved to other classes.

When should we create a private shared method option?

In most cases, I believe the first option will be your best choice to fix public method issues and will always be the easiest to implement.

My approach is to take the code you need moved to the private method and declare the private method as simply private void sharedCode() {…}.

At this point, you’ll see some errors in the new private method because parameters haven’t been set, and some variables or parameters from the public method will need to be passed to this new method to enable the code to compile. Use the red in your IDE to help you determine the parameters you need to pass in. I prefer to see red errors instead of a guess-and-check approach to create the private method — unless it’s a small private method, in which case it can be simple to identify the problem areas.

In most cases, the private method will need more parameters that are harder to determine upfront. In our code example, it’s easy to see that the only parameter we will need is the Orderobject. The only line in saveOrder is orderRepository.save(order), and that also happens to be the only line that will be in our new private method.

private Order saveOrderPrivate(Order order) {

return orderRepository.save(order);

}

And the public methods now look like this:

@Transactional(propagation=Propagation.REQUIRES_NEW)

@Override

public Order saveOrder(Order order) {

return this.saveOrderPrivate(order);

}

 

@Override

public void updateCustomerOrdersAsShipped(long custId) {

List<Order> ordersForCustomer = orderRepository.findAllOrdersForCustomer(custId);

for (Order customerOrder: ordersForCustomer) {

boolean isReadyForShipment = validateOrderReadyForShipment(customerOrder);

customerOrder.setShipDate(new LocalDate());

this.saveOrderPrivate(customerOrder);

}

}

Pitfall of this approach

One tradeoff to be aware of is code access. The code we moved into the private method will only be available to that class. If you want to share it with other classes, you will no longer have this access. You could potentially create an interface method with the same signature to pass all parameters down to the private method and return what it returns to fix this issue. In the case of our example, the saveOrder method would do just that. But, in many real-world scenarios, the code would be much more complex.

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.

Credits : Salon

 

If you’ve browsed job boards for web positions over the last few years, you’ve most likely encountered the term “full stack developer” in your searches. A full stack developer is an engineer who can handle everything from databases and servers to systems engineering and clients — and they can rake in upwards of six figures a year.

Tackling all of the skill sets you need to become an in-demand full stack developer takes time, but you can get a head start (and a resume-boosting certification) with the Beginner Full Stack Web Development course.

This class is a one-stop shop for front-end and back-end development. With more than 25 hours of content available to you 24/7, you can study at your own pace, kicking off with basic lessons in HTML and CSS. You’ll build your own website, learn to code with JavaScript, and manage that code with Git.

Industry-standard frameworks like Bootstrap will be a snap to manage after these lessons, and cross-platform JavaScript programs like Node, Mongo, and React will be at your fingertips. Once you’ve mastered the entire course, you’ll gain a well-earned certification to show off.

Usually, the Beginner Full Stack Web Development course goes for $200, but right now you can dive into web development for only $19 (90% off).

 

This article is shared by www.itechscripts.com | A leading resource of inspired clone scripts. It offers hundreds of popular scripts that are used by thousands of small and medium enterprises.