How to Code Complex Applications: Core Java Technology and Architecture

Processing of Complex Application: Background

Process Decomposition

  • Do the adopted tools form the core of the topic?
  • Does the code flexibility introduced by the design mode form the core of the topic?
@Command
public class OnSaleNormalItemCmdExe {
@Resource
private OnSaleContextInitPhase onSaleContextInitPhase;
@Resource
private OnSaleDataCheckPhase onSaleDataCheckPhase;
@Resource
private OnSaleProcessPhase onSaleProcessPhase;
@Override
public Response execute(OnSaleNormalItemCmd cmd) {

OnSaleContext onSaleContext = init(cmd);

checkData(onSaleContext);
process(onSaleContext); return Response.buildSuccess();
}
private OnSaleContext init(OnSaleNormalItemCmd cmd) {
return onSaleContextInitPhase.init(cmd);
}
private void checkData(OnSaleContext onSaleContext) {
onSaleDataCheckPhase.check(onSaleContext);
}
private void process(OnSaleContext onSaleContext) {
onSaleProcessPhase.process(onSaleContext);
}
}
@Phase
public class OnSaleProcessPhase {
@Resource
private PublishOfferStep publishOfferStep;
@Resource
private BackOfferBindStep backOfferBindStep;
//omit other steps
public void process(OnSaleContext onSaleContext){
SupplierItem supplierItem = onSaleContext.getSupplierItem();
// generate OfferGroupNo
generateOfferGroupNo(supplierItem);

// publish offer
publishOffer(supplierItem);
// bind back offer stock
bindBackOfferStock(supplierItem);
// synchroize sotck
syncStockRoute(supplierItem);
// set virtual product tag
setVirtualProductExtension(supplierItem);
// set procteciton label
markSendProtection(supplierItem);
// record Change Details
recordChangeDetail(supplierItem);
// synchronize price
syncSupplyPriceToBackOffer(supplierItem);
// set exteinsion info
setCombineProductExtension(supplierItem);
// remove sellout tag
removeSellOutTag(offerId);
// fire domian event
fireDomainEvent(supplierItem);

// close to-do issues
closeIssues(supplierItem);
}
}
  • Is a process engine required?
  • Is the support of a design mode required?

Post Process Decomposition Challenges

  1. Fragmented Domain Knowledge: There is no place for domain knowledge aggregation. The code for each use case is only specific to its own process, and the knowledge is not centrally accumulated. The same business logic is implemented repeatedly in multiple use cases, which leads to a severe code repetition. Though code can be reused, only one snippet can be extracted for reuse at most.
  2. Code Failure to Express Business Semantics: While coding for a process, it is expected to express how to obtain data, perform computation, and store the resulting data. In this case, it is hard to realize the same because models and the relationship between the models are missing. Being separated from models, business semantic expressions lose their rhythm and soul.
boolean isCombineProduct = supplierItem.getSign().isCombProductQuote();// supplier.usc warehouse needn't check
if (WarehouseTypeEnum.isAliWarehouse(supplierItem.getWarehouseType())) {
// quote warehosue check
if (CollectionUtil.isEmpty(supplierItem.getWarehouseIdList()) && !isCombineProduct) {
throw ExceptionFactory.makeFault(ServiceExceptionCode.SYSTEM_ERROR, "You cant publish offer, since there is no warehouse info");
}
// inventory amount check
Long sellableAmount = 0L;
if (!isCombineProduct) {
sellableAmount = normalBiz.acquireSellableAmount(supplierItem.getBackOfferId(), supplierItem.getWarehouseIdList());
} else {
//combination product
OfferModel backOffer = backOfferQueryService.getBackOffer(supplierItem.getBackOfferId());
if (backOffer != null) {
sellableAmount = backOffer.getOffer().getTradeModel().getTradeCondition().getAmountOnSale();
}
}
if (sellableAmount < 1) {
throw ExceptionFactory.makeFault(ServiceExceptionCode.SYSTEM_ERROR, "Your stock is less than 1, please supply more items. The product id:" + supplierItem.getId() + "]");
}
}
if(backOffer.isCloudWarehouse()){
return;
}
if (backOffer.isNonInWarehouse()){
throw new BizException("You cant publish offer, since there is no warehouse info");
}
if (backOffer.getStockAmount() < 1){
throw new BizException("Your stock is less than 1, please supply more items,The product id:" + backOffer.getSupplierItem().getCspuCode() + "]");
}

Process Decomposition Plus Object Models

Methodologies Used to Code Complex Applications

Top-down and Bottom-up Combination

Capability Sink-in

  1. Using Only Concepts: In this phase, you may understand few concepts of DDD, and eventually use some of them including the Aggregation Root, Bonded Context, Repository concepts while coding. Further, you may also use some layered strategies. However, this has little effect on complexity governance.
  2. Achieving Mastery: In this phase, terms become less important. You can understand the essence of DDD, which is a method of establishing a ubiquitous language, defining boundaries, and performing object-oriented analysis.

Code Reusability and Cohesion: Two Key criteria in the Sink-in

public class CSPU {
private String code;
private String baseCode;
//omit other attributes
/**
* check if it is minimumu unit
*
*/
public boolean isMinimumUnit(){
return StringUtils.equals(code, baseCode);
}
/**
* check if it is middle package
*
*/
public boolean isMidPackage(){
return StringUtils.equals(code, midPackageCode);
}
}

How Should We Practice Application Development

  • Should application development focus on business implementation or technology?
  • What is the technical significance of application development?
  • Consolidate their capabilities, including basic technical capabilities, object-orientation (OO) capabilities, and modeling capabilities.
  • Constantly improve abstract, structured, and critical thinking.
  • Continue to learn and improve code quality. We can do a lot of technical work as an application developer.

Postscript

Original Source

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Performance Optimization of Fuzzy Queries for Chinese Characters Using PostgreSQL trgm

IOT ALARM

Self-Driven Databases: Intelligent Parameter Tuning for Alibaba Databases Explained

How Alibaba Cloud Redis Can Be Used for High-Concurrency and Low Latency Scenarios

Handling images in a truly dynamic web environment

Apache Flink Fundamentals: Basic Concepts

Elasticity in the Storage of distributed Hadoop Cluster

Jersey Java RESTful API on an Alibaba Cloud ECS Instance

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Kafka — Everything you need to know

Redis and its alternatives: Important points to decide distributed caches

Kafka Dynamic Configuration & Multiple Error Handler

ROSETTA ERROR in starting Kafka Zookeeper on MAC M1