Beispiel #1
0
        //----< add a new data member >------------------------------------
        public void addDataMember(string type, string name)
        {
            if (findDataMember(type, name) == -1)
            {
                CMemberInfo memberInfo = new CMemberInfo();

                memberInfo.type = type;
                memberInfo.name = name;

                dataMembers.Add(memberInfo);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            CClassList classList = new CClassList();

            CClassInfo classInfo = new CClassInfo();

            classList.classList.Add(classInfo);

            // CLASS B
            classInfo.className = "CTestClassA";
            classInfo.dependencies.Add("cdCToken");
            classInfo.dependencies.Add("cdITem");
            classInfo.dependencies.Add("cdString");

            CMemberInfo memberInfo = new CMemberInfo();

            memberInfo.type = "cmA";
            memberInfo.name = "nameA";
            classInfo.dataMembers.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            classInfo.dataMembers.Add(memberInfo);

            // FUNCTION A
            CFunctionInfo functionInfo = new CFunctionInfo();

            functionInfo.name = "fnTestFunction1";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmA";
            memberInfo.name = "nameA";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            // FUNCTION B
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction2";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmZ";
            memberInfo.name = "newItemA";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            // FUNCTION C
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction3";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmJ";
            memberInfo.name = "newItemB";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            classInfo = new CClassInfo();
            classList.classList.Add(classInfo);

            // CLASS B
            classInfo.className = "CTestClassB";
            classInfo.dependencies.Add("yellow");
            classInfo.dependencies.Add("orange");
            classInfo.dependencies.Add("green");

            memberInfo      = new CMemberInfo();
            memberInfo.type = "Monkey";
            memberInfo.name = "dave";
            classInfo.dataMembers.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "Car";
            memberInfo.name = "Toyota";
            classInfo.dataMembers.Add(memberInfo);

            // FUNCTION A
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction1B";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "Monkey";
            memberInfo.name = "dave";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "Snake";
            memberInfo.name = "Python";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            // FUNCTION B
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction2B";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "Bug";
            memberInfo.name = "Beatles";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "Snake";
            memberInfo.name = "Python";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            // FUNCTION C
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction3B";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "Computer";
            memberInfo.name = "Dell";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "Computer";
            memberInfo.name = "HP";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            Console.WriteLine("Break here and observe ParsedData data structure.");
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            CClassList classList = new CClassList();

            CClassInfo classInfo = new CClassInfo();

            // CLASS
            classInfo.className = "CTestClass";
            classInfo.dependencies.Add("cdCToken");
            classInfo.dependencies.Add("cdITem");
            classInfo.dependencies.Add("cdString");

            CMemberInfo memberInfo = new CMemberInfo();

            memberInfo.type = "cmA";
            memberInfo.name = "nameA";
            classInfo.dataMembers.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            classInfo.dataMembers.Add(memberInfo);

            // FUNCTION A
            CFunctionInfo functionInfo = new CFunctionInfo();

            functionInfo.name = "fnTestFunction1";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmA";
            memberInfo.name = "nameA";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            // FUNCTION B
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction2";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmZ";
            memberInfo.name = "newItemA";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            // FUNCTION C
            functionInfo      = new CFunctionInfo();
            functionInfo.name = "fnTestFunction3";

            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmB";
            memberInfo.name = "nameB";
            functionInfo.dataMemberReferences.Add(memberInfo);
            memberInfo      = new CMemberInfo();
            memberInfo.type = "cmJ";
            memberInfo.name = "newItemB";
            functionInfo.dataMemberReferences.Add(memberInfo);

            classInfo.functionInfoList.Add(functionInfo);

            int cohesion = calculateCohesion(classInfo);

            int coupling = calculateCoupling(classInfo);

            Console.WriteLine("cohesion {0}, coupling {1}", cohesion, coupling);
        }