How to document the high-level structure of a Java program?

Background:
My collaborators and I are writing an article for an academic journal.
In the course of our research,
we wrote a simulation program in Java.
We want to make the simulation program freely available for others to use.
We have decided on hosting the code on a GitHub repository.
In order to make it easy for others to use,
we want to write good documentation for our program, including:

  • Javadocs for each class and method
  • How to use the code
  • Describing the high-level structure of the code

My high-level question is:
Could you provide a good example of the words and diagrams
that can be used to describe the high-level structure of a program?

This includes as sub-questions:

  1. How do we show what classes are contained in which packages?
  2. How do we show what packages depend on other packages?
  3. How do we show how the objects/classes in the program work together?
  4. We have tried to use domain-driven design principles
    in the design of my code.
    How do we show the correspondence between the objects in the domain
    and the particular source code files encoding these objects?
    (See my “ubiquitous language” description of the project below.)

What I have done so far

Ubiquitous language

We put a “ubiquitous language” description of the code
in a file ubiquitous-language.md,
contents below.

The purpose of this project is to study how well a replenishment policy
performs in a simple supply chain with a single facility,
under different lead time models, report delays and demand models.

In each period, the following events occur:

  1. If a shipment is scheduled to arrive at the facility at the
    current period, then the inventory level of the facility is
    incremented by X units.
  2. If the schedule indicates that the current period is a reporting
    period, then the facility submits a report to the
    supplier. The supplier may receive the report
    instantaneously, or with a delay of several weeks, as specified by
    the schedule.
  3. If the supplier has received a report, then based on the
    replenishment policy, it will calculate a replenishment
    quantity of X units. A shipment of X units of the product will
    be scheduled to arrive after a lead time of l periods.
  4. Customers arrive at the facility and demand X units of the
    product. Any unmet demand is lost.

Source Code Structure

We put an incomplete “high-level” description of the code
in a file structure.md,
contents below.

Package Level Structure

At the highest level, the source code is organized into three packages

  • com.gly.sfs
    The main class with the main method resides in this package.
  • com.gly.sfs.model
    The domain model classes reside in this package.
  • com.gly.sfs.util
    Helper classes reside in this package.

5

Normally, you’d use UML for the purpose you describe. UML basically breaks down into two types of diagrams: structural and behavioral.

Structural diagrams include: composition, deployment, package, class, object, and component. Behavioral diagrams include: sequence, state machine, communication, use case, activity, and interaction overview.

Depending on what you’re trying to convey, you pick a few of these diagrams which best represent whatever you’re trying to convey, and by so doing you allow the conversation to “move up a level”. Instead of talking about methods, parameters, and code, you’re talking about sequence of interactions, or static class dependencies, or whatever diagrams you choose to create.

I’ve attached an example of a sequence diagram (one of the behavior diagrams). I personally like the sequence diagram because it’s right in the middle of the design artifact process — roughly an equal number of diagrams depend on it as it expects as input. I find that the input diagrams are typically “understood” anyway, or the sequence diagram already implies their existence. However, sometimes I do both static class diagrams and sequence diagrams (one structural and one behavioral diagram).

http://omarfrancisco.com/wp-content/uploads/2011/07/sequencediagram.png

I have never seen this diagram before in my life, but I can tell a number of things about this system. There are four major components (the nouns in your system — typically the classes): View, Controller, Data Proxy, and Data Provider. The arrows are “behaviors” or method invocations. A sequence diagram is basically good for showing a single important interaction between a bunch of components. You have one sequence diagram for each important flow through your system. I can tell from this particular diagram that “Controller” exposes a method called “phoneIsComplete()”, which in turn depends on DataProviderProxy’s “lookupPhone()” method, which in turn depends on DataProvider’s “lookupPhone()” method.

Now, you might groan and think “uggg… this doesn’t give me a big picture of the system — it’s just individual interactions through the system”. Depending on the sophistication of the system, that might be a valid concern (simple systems can definitely get by with just a collection of sequence diagrams). So, we move over to the structural diagrams and we look at something like a static class diagram:

http://www.f5systems.in/apnashoppe/education//img/chapters/uml_class_diagram.jpg

Class diagrams help us figure out two important things: cardinality, and class relationship types. Classes can be related to one another in different ways: association, aggregation, and composition. Technically speaking, there’s a difference between “static class relationships” and “instance relationships”. However, in practice you see these lines blurred. The main difference is that static class relationships don’t usually include cardinality. Let’s look at the example above and see what we can see. First, we can see that “Special Order” and “Normal Order” are subtypes of “Orders” (inheritance). We can also see that one Customer has N Orders (which may be “Normal Orders”, “Orders”, or “Special Orders”) — the Customer object doesn’t really know. We can also see a number of methods (in the bottom half of each class box) and properties (top half of each class box).

I could keep talking about UML diagrams for a long time, but this is the basics. Hopefully that helps.

TLDR; Pick one behavioral and one structural UML diagram, learn how to create it, and you’ll accomplish what you’re trying to accomplish.

0

If you’re having difficulty describing things like how the high-level structure of your program works, and how the classes work well together, consider the following maxim:

A picture is worth a thousand words.

The way you paint a picture about code is to provide code examples. Lots of them. This is how you create a new customer (code). This is how you process an order (code). Not only does this give the consumer of your code a place to start, it illustrates how all of the objects connect together and interact. If I were using your code, the biggest favor you could do me is to provide lots of code samples.

The way you paint a picture for an end-user is to provide screenshots. Lots of them. Screenshot after screenshot that illustrates, if you want to do this task, this is what you do first, this is what you do next, etc.

7

UML, while often used to model software before it is created, could be useful. There are several different diagrams that illustrate use-cases, class-interactions, etc. etc. You can see more about it here.

I find https://www.websequencediagrams.com/ an extremely useful tool for describing the interaction between components within an application, or between services in a distributed application. It just makes the process of creating and maintaining UML sequence diagrams much easier.

The nice thing is, if you consider each lifeline to be the interface or class in your application (I usually just model the big players), then each line flowing into that class represents a method that you must support.

Additionally, there are some download options to get the image. There are also some easy ways to embed the diagram in a wiki. So it’s a great communication tool to describe the interaction between components or services in a system, as well as communicating that with the team.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật