concept business logic in category java

This is an excerpt from Manning's book JUnit in Action.
An inner class is a class that is a member of another class. It can access any private instance variable of the outer class, as it is effectively part of that outer class. The typical use case is when two classes are tightly coupled, and it’s logical to provide direct access from the inner class to all instance variables of the outer class. For example, we may test a flight that has two types of passengers trying to board. The behavior of the flight will be described in the outer test class, while the behavior of each type of passenger will be described in its own nested class. Each passenger is able to interact with the flight. The nested tests will support following the business logic and lead to writing clearer code, as you will be able to easier follow the imbricated tests.
Figure 20.12 Running the full tests suite (economy, business, and premium flights) after adding the business logic for PremiumFlight: code coverage is 100%.
![]()
John follows the business logic of each step that has been defined and translates it into the tests from listing 21.4—the steps of the scenarios that need to be verified.
Listing 21.4 Implementing the business logic of the previously defined steps
public class PassengerPolicy { private Flight economyFlight; #1 private Passenger mike; #1 [...] @Given("^there is an economy flight$") #2 public void there_is_an_economy_flight() throws Throwable { #2 economyFlight = new EconomyFlight("1"); #3 } @When("^we have a regular passenger$") #4 public void we_have_a_regular_passenger() throws Throwable { #4 mike = new Passenger("Mike", false); #5 } @Then("^you can add and remove him from an economy flight$") #6 public void you_can_add_and_remove_him_from_an_economy_flight() #6 throws Throwable { assertAll("Verify all conditions for a regular passenger #7 and an economy flight", #7 () -> assertEquals("1", economyFlight.getId()), #7 () -> assertEquals(true, economyFlight.addPassenger(mike)), #7 () -> assertEquals(1, #7 economyFlight.getPassengersSet().size()), #7 () -> assertTrue(economyFlight.getPassengersSet().contains(mike)), #7 () -> assertEquals(true, economyFlight.removePassenger(mike)), #7 () -> assertEquals(0, economyFlight.getPassengersSet().size()) #7 ); } [...] }

This is an excerpt from Manning's book AspectJ in Action, Second Edition.
Code tangling is caused when a module is implemented to handle multiple concerns simultaneously. Developers often consider concerns such as business logic, performance, synchronization, logging, security, and so forth when implementing a module. This leads to the simultaneous presence of elements from each concern’s implementation and results in code tangling. Figure 1.2 illustrates code tangling in a module.
Figure 1.2. Code tangling caused by multiple simultaneous implementations of various concerns. This figure shows how one module manages parts of multiple concerns.
![]()
Another way to look at code tangling is to use the notion of a multidimensional concern space. Imagine that you’re projecting the application requirements onto a multidimensional concern space, with each concern forming a dimension. Here, all the concerns are mutually independent and therefore can evolve without affecting the rest. For example, changing the security requirement from one kind of authorization scheme to another shouldn’t affect the business logic. But as you see in figure 1.3, a multidimensional concern space collapses into a one-dimensional implementation space.
So far in this book, we’ve established that AOP is useful for implementing crosscutting infrastructure functionality such as monitoring, concurrency control, transaction management, and security. Those crosscutting concerns are often the first you’ll implement with AOP. But AOP is also useful in improving the implementation of domain logic in several ways. First, aspects help in implementing dependency injection (DI) for objects not explicitly managed by a DI container. This enables the implementation of complex behavior that would otherwise be tedious. Second, by modularizing crosscutting business logic, AOP provides the same benefits it offers to crosscutting infrastructure concerns. Furthermore, AOP helps enforce design rules targeted toward the domain objects, improving the overall quality of the software system.