Questions tagged [code-complexity]

Code complexity is measure of the degree of complexity in code.

It is influenced by numerous factors such as: Average Hierarchy Height, Average Number of Derived Classes, Afferent Coupling, Efferent Coupling, number of “if” condition statements, and many others. Computer scientists have been measuring code complexity for decades. A widely used and intuitive measure is cyclomatic complexity, introduced in 1976.

191 questions
47
votes
18 answers

Code Bowling on "Hello World"?

Contrary to the popular code-golf challenges which demonstrate the genius of many regulars here, I'd like to see that genius illustrated in an antithetical fashion. The challenge is to successfully perform "Hello World" with special focus on…
Sampson
  • 265,109
  • 74
  • 539
  • 565
39
votes
28 answers

How complex should code be?

I'm studying about algorithms which can help me write smaller but more complex code. Instead of writing 150 lines of if-else statements, I can design an algorithm that does it in 20 lines. The problem is a lot of these algorithms can be complex…
danmine
  • 11,325
  • 17
  • 55
  • 75
20
votes
20 answers

What's the HARDEST program you've written?

Just curious, I'm wondering what all you experienced programmers or newbies (like me) out there have done. So what's the HARDEST most complicated program you've written?
RaouL
  • 1,133
  • 4
  • 14
  • 17
14
votes
5 answers

Maintainability Index

I have come across the recommended values for a Maintainability Index (MI) as follows: 85 and more: good maintainability 65-85: moderate maintainability 65 and below: difficult to maintain with really bad pieces of code (big,…
Ani
14
votes
10 answers

Find the length of the longest valid parenthesis sequence in a string, in O(n) time

My friend ran into a question in an interview and he was told that there is an O(n) solution. However, neither of us can think it up. Here is the question: There is a string which contains just ( and ), find the length of the longest valid…
11
votes
2 answers

The complexity of the multiplication of two lower triangular matrices

I know that the lower bound of the multiplication of two full matrices is Ω(n^2). Matrix multiplication I have been trying to prove that the lower bound of the multiplication of two lower triangular matrices using problem transformation method. My…
Alex Lin
  • 395
  • 3
  • 13
10
votes
2 answers

Are there any code complexity metering tools that work well with ES6?

My project is ES6 (webpack + babel). Plato is great, but doesn't work with ES6 yet. I took a look at escomplex and the series of related packages, but it looks like the author is no longer maintaining this and it seems like it doesn't support ES6…
sak_to
  • 399
  • 4
  • 13
9
votes
2 answers

bisect.insort complexity not as expected

trying to find the most optimal data structure in python3 for a frotier problem i have to develop have just realised that the complexity of using the module bisect to make a real time ordered insert is not O(nlog n) as it should be and grows…
jupcan
  • 436
  • 3
  • 7
  • 17
9
votes
5 answers

Reducing code complexity for GWT

I started learn GWT by example on google and my first conclusion is: too much code Like this: stocks.add(symbol); stocksFlexTable.setText(row, 0, symbol); stocksFlexTable.setWidget(row, 2, new Label()); …
ziftech
  • 747
  • 1
  • 10
  • 22
8
votes
0 answers

How can I disable the McCabe test MC0001 in Landscape.io?

Landscape.io offers nice and good Python code tests and based on PEP 8, Pylint, McCabe, etc. Some of my parser methods contain big switch blocks, so I would like to disable the McCabe test MC0001 for selected methods. How can I do this? I found this…
Paebbels
  • 15,573
  • 13
  • 70
  • 139
7
votes
1 answer

Sonar integration with lizard to track code complexity failing in android studio

I am trying to integrate lizard to track the code complexity of an android app on sonarqube. The command used to get the complexity report from lizard is: lizard src/main -x"./test/*" -x"./androidTest" --xml >lizard/lizardReport.xml In the…
7
votes
4 answers

C++ Templating vs Inheritance

I just realize how hard asking questions can be... Hopefully I can give examples that are both, sufficiently precise to demonstrate my problem and short enough not to mess everything up... At least there's the possibility to edit. So this is kind of…
b.buchhold
  • 3,837
  • 2
  • 24
  • 33
7
votes
2 answers

confirmation email as a Data Element Type - Function Points

I understand that a confirmation message on a UI is counted as a Data Element Type (DET). What if my confirmation message is an alert box on a UI plus an email confirmation. Should i count it as 1 DET or 2 DETs Thanks
stud91
  • 1,854
  • 6
  • 31
  • 56
6
votes
2 answers

How do I reduce the "Cyclomatic Complexity" of the following code

I am wondering how to reduce the Cyclomatic Complexity of the following code and if this is even something that I should be worried about. Please refer to the method ValuePojo.getSomething() (Please don't worry about the variable naming, this has…
Corey Scott
  • 2,430
  • 3
  • 28
  • 33
5
votes
2 answers

What does O(logn) + O(n) mean?

I was just told by someone that my code should follow the complexity guideline of O(logn) + O(n). When prompted for clarification, I was presented with, "the complexity of the code :)" In any event, any clarification over and above the provided…
Benjamin Powers
  • 3,186
  • 2
  • 18
  • 23
1
2 3
12 13