Relative Content

Tag Archive for methods

Math library methods in Google’s Go Programming Language

I have been programming in google Golang and have been enjoying it due to its brevity but I find it surprising that almost all its Math standard library methods are for the floating point type. Is there any particular reason why these methods do not exist for ints?

Understanding high cohesion principle for methods in object oriented design

I know the idea of strong cohesion applies to methods as much it applies to classes. Just to be clear when I say strong cohesion of a method I mean a method which does only one task and does it well. This idea really works for simple getters and setters. But sometimes we usually come across methods that does more than one task internally , although it seems to be doing a single task if you look at a higher level of abstraction. An example of such a method can be :

Naming functions that retrieve a value

I have this personal rule to start all function/method names with a verb. My verb of choice for functions or methods that get a value based on some data structure or object is get. I’m wondering if that’s a good idea.

Is it a good practice to write a method that gets something and checks the value? [duplicate]

This question already has answers here: Should a method do one thing and be good at it? [duplicate] (3 answers) Style for control flow with validation checks (4 answers) Closed 11 years ago. Occassinally I have to write methods like this: string GetReportOutputDirectoryAndMakeSureExist() { string path = Path.Combine ( … ) //whatever logic if(!Directory.Exists(path)) Directory.Create(path); […]

What is the reason for using lowercase for the first word in a local variable (eg, employeeCount, firstName)

I take a good deal of criticism from other programmers due to my use of full proper casing for all my variables. For example, your typical programmer will use employeeCount for a variable name, but I use EmployeeCount. I use full proper casing for everything, be it a void method, return method, variable, property, or constant. I even follow this convention in Javascript. That last one really rustles people’s jimmies.

What is the reason for using lowercase for the first word in a local variable (eg, employeeCount, firstName)

I take a good deal of criticism from other programmers due to my use of full proper casing for all my variables. For example, your typical programmer will use employeeCount for a variable name, but I use EmployeeCount. I use full proper casing for everything, be it a void method, return method, variable, property, or constant. I even follow this convention in Javascript. That last one really rustles people’s jimmies.