One of the most trivial grouping of classes into packages is grouping by their technical type:

org.acme.shop
	.controller
		.CatalogController
		.CartController
		.OrderController
		.PayPalController
	.dto
		.CartDto
		.CategoryDto
		.PaymentDto
		.ProductDto
		.PhotoDto
	.enum
		.DeliveryMethod
		.PaymentStatus
		.ProductType
	.exception
		.PayPalException
		.WarehouseException

Domain related grouping would be better:

org.acme.shop
	.catalog
		.CatalogController
		.CategoryDto
		.ProductDto
		.ProductType
		.PhotoDto
	.cart
		.CartController
		.CartDto
	.order
		.DeliveryMethod
		.OrderController
		.PaymentDto
		.PaymentStatus
		.PayPalController
		.PayPalException
		.WarehouseException

Even a programmer that is new to a project can easily see that a class is a MVC controller, a DTO object, an exception or an enum and he knows how those different type of classes work with each other. Such technical knowledge is our area of expertise.

What every programmer may not know is what are the business concepts – which classes form a group that fulfills a specific part of business process, especially if the domain is something less common than an online shop. Therefore strive for non trivial grouping of classes that will carry some business meaning to other programmers.

W. Gdela

            Votes: 0

See more like this: