Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
YouTube Security VideosNutanix advances legacy and AI app management with AMD(01.10.2026 um 16:00 Uhr)
•
YouTube Security VideosPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••••
Videos & KonferenzenPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••
Sicherheitslücken (CVE)USN-8857-1: KCoreAddons vulnerability(01.10.2026 um 12:48 Uhr)
•••
YouTube Security VideosNutanix advances legacy and AI app management with AMD(01.10.2026 um 16:00 Uhr)
•
YouTube Security VideosPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••••
Videos & KonferenzenPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••
Sicherheitslücken (CVE)USN-8857-1: KCoreAddons vulnerability(01.10.2026 um 12:48 Uhr)
•••
Intelligence View
⚡ tsecurity.de Intelligence

On Code Style Guides

A short post about why code style guides matter, and an easy way to create one. Why Code Style Guides? A coherent code style makes code easier to read because…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

A short post about why code style guides matter, and an easy way to create one.






Why Code Style Guides?



A coherent code style makes code easier to read because it reduces visual noise and cognitive load. For example, take these two ways to present the same math question:




        |\                      |\               a = 5
| \ | \ b = 3
5 | \ ? a | \ ?
| \ | \
|________\ |________\
3 b






Although, whether you can solve the question doesn't depend on the way it's presented, the first way 'feels' easier.

There's less cognitive strain.




Extrinsic vs Intrinsic Complexity


The question above has intrinsic complexity, that is complexity that's inherent to the problem. You have to know Pythagoras' theorem (a^2 + b^2 = c^2) to solve it.


But, the second way of presenting the problem adds extrinsic complexity to the problem. That is complexity that is not inherent to the problem and is as such unnecessary.




Similarly, badly formatted code adds unnecessary complexity for the reader. Since we are pattern matching machines, even tiny irregularities can lead to short distractions. E.g. a brace in the wrong place, a comma attached to the wrong token, ...



Let's compare two examples. We start with a very messy "code style":




public  class Foo extends  Bar {
private String _someMember;
private int SomeOtherMember;

public Foo(String someParam)
{
_someMember = someParam;
}

public void do() {
if (_someMember != null && _someMember.equals(SomeOtherMember.toString())
{
if (_someMember.length() > 10) {
// do something
}
}
else
{
// do something else
}
}

public void DoSomethingElse() { _someMember = "foo"; SomeOtherMember = "bar"; }
}






There is no consistent naming, e.g. methods use Pascal (DoSomeThingElse()) or camel case (do()). Indentation is messy, it's hard to see to which if the else belongs, ...



Let's try to get this piece of code more consistent, more readable:




public class Foo extends Bar {
private String _someMember;
private int _someOtherMember;

public Foo(String someParam) {
_someMember = someParam;
}

public void do() {
if (_someMember != null && _someMember.equals(someOtherMember.toString()) {
if (_someMember.length() > 10) {
// do something
}
} else {
// do something else
}
}

public void DoSomethingElse() {
_someMember = "foo";
_someOtherMember = "bar";
}
}






Whether you agree with the specific code style or not, I think we can all agree, that the second version is easier to

read than the first one.






How to Create a Style Guide?



I like to start easy. For example for Java I just use

the Google Java Style Guide with some minor modifications.



If you use an IDE with extensive options to configure a code style, like Android Studio does for example. I like to make it easy on my fellow developers and me. The code style gets configured in the IDE and I only describe the things that cannot be automated/enforced by the IDE. These are guidelines on comments, naming where to best line wrap, ... . An example for a minimal code style guide could look like follows (start small).







%Your Company Name% Java Style Guide



This style guide is based on the Google Java Style Guide.



All formatting is configured in the project's code style settings file, so you don't have to worry about where the braces go, how many whitespaces to use when indenting, ... - this is all being taken care of by the IDE.



There are however a number of things that the IDE can't or shouldn't do for you. These things are addressed in the rest of this style guide.





Ordering of class contents



...





Line-wrapping



...





Comments



...

Use comments mainly to explain why you do something the way you do it. What your doing should be clear from the code. Use descriptive names for methods and variables.




Every time you write a comment, you should grimace and feel the failure of your ability of expression.


Robert C. Martin







In the end it doesn't matter which style you choose, the only thing that matters is that you use one.

🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

Bedrohungsgraph · ATT&CK-Mapping · Exploit-Belege
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten On Code Style Guides

Thematisch verwandte Begriffe: Code, Style, Guides · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag