MOOD Factors to Assess a Java Program17 Mar 2025 | 6 min read Application quality is critical to the development of software systems, especially large-scale ones. High quality software would reduce the cost of software maintenance, and it enhances the potential software reuse. In order to measure the software quality more quantitatively and objectively, software metrics (MOOD) give impression to be a powerful and effective methodology that decide a grade to an object-oriented application. So, in this section, we will discuss the mood factors to assess an object-oriented application. ![]() MOOD stands for Matrices for Object Oriented Design. It describes the characteristics of an object-oriented application or program. It is used to evaluate a grade of Java program. MOOD factors include the following six software quality indicators or metrices:
Information Hiding factorsMHF and AHF are measures of the use of the information-hiding concept supported by the encapsulation mechanism. Information hiding should be used to:
Method Hiding Factor (MHF)MHF can be calculates by using the following mathematical formula: ![]() Where, Mh(Ci) = hidden Methods in class Ci Md(Ci) = Mv(Ci) + Mh(Ci): Methods defined in Ci Mv(Ci): visible Methods in class Ci TC: Total number of Classes The visible methods measure the class functionality. Enhancing the overall functionality of the class, reduces the MHF. In order to implement this functionality, a top down approach must be adopted. It means that the class implementation must be a step by step decomposition process so that we can add more and more detail in hidden methods that results in incremented MHF. A very low MHF value denotes implementation of insufficiently abstracted methods. Conversely, a high MHF value denotes very little functionality. Therefore, the MHF values must lies within an interval 2,3, and 4. Attribute Hiding Factors (AHF)AHF can be calculates by using the following mathematical formula: ![]() Where, Ah(Ci) = hidden attributes in class Ci Ad(Ci) = Av(Ci) + Ah(Ci): attributes defined in Ci Av(Ci): visible attributes in class Ci TC: Total number of classes AHF is a measure of the use of the information hiding concept supported by the encapsulation mechanism. Information hiding allows coping with complexity by turning complex components into black boxes. AHF should be used as much as possible. Ideally all attributes would be hidden, thus being only accessed by the corresponding class methods. Very low values of AHF should trigger the designers' attention. In general, as AHF increases, the complexity of the program decreases 2,3, and 4. Inheritance FactorsBoth MIF and AIF are measures of inheritance. This is a mechanism for expressing similarity among classes that allows for the portrayal of generalization and specialization relations, and a simplification of the definition of inheriting classes by means of reuse [2,3,4,5]. Method Inheritance Factor (MIF)MIF can be calculated by using the following mathematical formula: ![]() Where, Mi: inherited methods Ma(Ci) = Md(Ci) + Mi(Ci): attributes defined in Ci Md(Ci): defined methods TC: Total number of classes At first sight, we might be tempted to think that inheritance should be used extensively. However, the composition of several inheritance relations builds a directed acyclic graph (inheritance hierarchy tree), whose depth and width make understandability and testability fade away quickly [1,2,3,4]. Attribute Inheritance Factor (AIF)AIF can be calculated by using the following mathematical formula: ![]() Where, Ah(Ci) = hidden attributes in class Ci Ad(Ci) = Av(Ci) + Ah(Ci): attributes defined in Ci Av(Ci): visible attributes in class Ci TC: Total number of classes Coupling Factor (COF)It measures the coupling between classes. COF can be calculated by using the following mathematical formula: ![]() Where, is_client(Cc,Cs) =| 1 if (Cc⇒Cs)^(Cc≠Cs) , 0 otherwise TC: It denotes the total number of classes. The client-supplier relation, represented by Cc ⇒ Cs, means that Cc (client class) contains at least one noninheritance reference to a feature (method or attribute) of class Cs (supplier class). The COF numerator represents the actual number of coupling not imputable to inheritance 2, 3, 4, and 6. It is desirable that classes communicate with as few other classes as possible, and that they exchange as little information as possible. Coupling relations increase complexity, reduce encapsulation and potential reuse, and limit understandability and maintainability. Also, coupling in software systems has a strong negative impact on software quality, and therefore should be kept to the minimum during the design phase. However, for a given application, classes must cooperate to deliver some kind of functionality. Therefore, COF is expected to be lower bounded 2, 3, and 4. Polymorphism Factor (POF)Polymorphism means having the ability to take several forms. In OO systems, polymorphism allows the implementation of a given operation to be dependent on the object that "contains" the operation 2, 3, 4, and 6. ![]() Where, Mo(Ci): overriding Methods in class Ci Mn(Ci): new Methods in class Ci DC(Ci): number of Descendants of Class Ci (derived classes) TC: Total number of Classes The POF numerator represents the actual number of possible different polymorphic situations. A given message sent to class Ci can be bound, statistically or dynamically, to a named method implementation which may have as many shapes as the number of times this same method is overridden (in Ci descendants) 2, 3, 4. Polymorphism arises from inheritance. Binding (usually at run time) a common message call to one of several classes (in the same hierarchy) is supposed to reduce complexity and to allow refinement of the class hierarchy without side effects. On the other hand, to debug such a hierarchy, by tracing the control flow, this same polymorphism would make the job harder. Therefore, polymorphism ought to be bounded within a certain range 2, 3, 4. Evaluation of MOOD FactorsThe grade awarded to an object-oriented program depends on the following table that is based on experiments.
The final grade is computed by using the following steps: Step 1: For all the indicators do the following: IF the indicator value is found within the specified range, THEN GRADE = 100% ELSE IF the indicator value is located in the tolerance range, THEN 60%≤GRADE by using interpolation. ELSE, the indicator outside the tolerance range, then GRADE<60% by using interpolation formula and the system should trigger the programmer's attention to a problem. ![]() Where, GRADE [i]: the grade for the indicators i. W[i]: weight value assigned to the indicator to reflect its importance. n: It is the number of factors, n=6. ![]() Where, FINAL GRADE: It represents the final grade of the evacuated object-oriented program [0:100]. TW: It represents the total weight that can be computed by using the following formula: ![]() Where, n: the total number of indicators, n=6. W(Fi): the weight for indicator i. The grade of each indicator ranges from 0% to 100%. Each indicator is assigned a weight to reflect its importance. The classification of the six indicators is shown in the following table. This table is produced from reported study 2, 3, 4, 5, and 6.
Let's consider the following design patterns and evaluate their grade using MOOD factors. ![]() Let's evaluate the grade for the above design pattern.
Base on the above evaluation, we have recommended the following:
We observe that each MOOD factor is associated with basic structural mechanisms of the object-oriented model. It is the mechanism that enables some recommendations for designers. The interval of each MOOD factor has been altered that is based on experimental results, to be fit in the evaluation of Java Programs. The weight factor reflects the importance of each characteristic. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Untouchable Number in Java
In this section, we will learn what is an untouchable number and also create Java programs to check if the given number is an untouchable number or not. The untouchable number program is frequently asked in Java coding interviews and academics. Untouchable Number A number N is called...
3 min read
Can Abstract Classes Have Static Methods in Java
? Java classes that cannot be instantiated but can offer a set of methods and attributes for their concrete subclasses to implement are known as abstract classes. Abstract classes are frequently utilized to build a group of similar classes that share some behaviors but differ in other...
4 min read
Java Program To Print Even Length Words in a String
Given a string str, write a Java program to print all words with even length in the given string. Example 1: Input: t= She sells seashells by the seashore Output: By Seashore Example 2: Input: t= To be or not to be, that is the question Output: To be or to that is question Approach: Using split() method The split() method is a...
2 min read
Object Life Cycle in Java
Based on the idea of object-oriented programming, or OOP, Java is a flexible and popular programming language. Everything in Java is an object, and objects go through many stages in their lifetime. In order to ensure proper resource management and program functioning, Java developers need to...
4 min read
DecimalFormat getPositivePrefix() method in Java
The Java DecimalFormat class's getPositivePrefix() method is used to retrieve this DecimalFormat instance's positive prefix value. Syntax: public String getPositivePrefix() Parameters: No parameter is accepted by this method. Return Value: The positive prefix value of this DecimalFormat object is returned by this method. Example 1: The formatting options for numeric numbers...
2 min read
Java Code for DES
Our dependency on the internet is increasing day by day and we share lots of personal information with others. Since our data or personal information is not secure. For this reason, the security of the data become essential for us. We need to keep data confidential,...
6 min read
Identical Linked List in Java
Identical linked lists are two linked lists with the same data in the same order. To determine if two linked lists are similar in Java, we compare corresponding nodes iteratively or recursively. It involves checking both the data and structure until all nodes match or a...
8 min read
Chained Exceptions in Java
In Java, a chained exception is a technique that enables programmers to associate one Exception with another. By providing additional information about a specific exception, debugging can be made easier. A chained exception is created by wrapping an existing exception in a new exception, which becomes...
6 min read
Java Cron Expression
The technology is constantly changing day by day. Sometimes, we are required to execute a job periodically on the server. Running the job on the server manually is a difficult task so, it cannot be done multiple times by the user or administrator. In order to...
8 min read
Why String is Immutable or Final in Java
? In object-oriented programming, the immutable string or objects that cannot be modified once it is created. But we can only change the reference to the object. We restrict to change the object itself. The String is immutable in Java because of the security, synchronization and concurrency,...
4 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India










