1. Best Practices

Thinking about the scope thread going on right now, I wonder if we don't need a lint checker that goes through and ensures best practices. For example, the whole debate about the scope issue is almost non-existant in most code I work on because there are not top level variables. In general top level variables are bad business. Top level constants, yes. Variables? No.

Even if there is not a lint tool, a wiki page wiki:BestPractices could be solving a whole lot of these problems. I propose we begin to create such a page. There is the wiki:CodingConvention page that contains some wiki:BestPractices but there are hundreds of wiki:BestPractices that would not really fall under a coding convention.

I also think that we would need some type of criteria as to what is a best practice and what is a "my style" practice. For example, one may say a best practice is to use camelCaseVariableNames starting with a lower case letter and function/procedures be named camel case starting with an upper case letter SuchAsThis(). I'm not really sure that could be considered a "best practice." There are different naming conventions such as use_underscores. Now is not using variables named a, b, c to mean first name, last name and birth date could be a best practice, i.e. make your variables descriptive and concise.

Jeremy

new topic     » topic index » view message » categorize

2. Re: Best Practices

This will be a fun thread to watch smile

Chris

new topic     » goto parent     » topic index » view message » categorize

3. Re: Best Practices

ChrisB said...

This will be a fun thread to watch smile

Chris

heh heh heh, yeah! But at the very least, all of us non-professional programmers will get a chance to see quite a variety of "best practices", and even perhaps some of the reasoning behind some of them, both of which should be interesting, and possibly helpful, too.

Dan

new topic     » goto parent     » topic index » view message » categorize

4. Re: Best Practices

I was looking at cmd_parse() documentation

What about adding "write functions with simple interface" to best practices. blink

new topic     » goto parent     » topic index » view message » categorize

5. Re: Best Practices

coconut said...

I was looking at cmd_parse() documentation

What about adding "write functions with simple interface" to best practices. blink

Simple tasks can have simple interfaces. Complex tasks rarely can have simple interfaces. However:

map args = cmd_parse({ 
    { "o", 0, "Output directory", { HAS_PARAMETER } }, 
    { "v", 0, "Verbose mode" } 
}) 

Is pretty simple for what you get. Full command line parsing including extras, nicely formatted help screens, argument validation (checking ones supplied are valid and erring with usable information when one is supplied that is not allowed, checking that those that require parameters have parameters). If you take the above 4 lines of code and implement that in your program the old fashioned way... It's pretty simple.

Now, where your tip comes into play is having a simple process with a complex interface. That indeed is terrible. I do not think that rule applies, however, to man:std_cmdline#cmd_parse. The docs can look daunting for that method, I agree. Maybe what is needed is a bare bones example up front such as the one above.

Jeremy

Just added ticket:585 which will be part of 4.0.1 release.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Best Practices

Merely a question:

(and I know how Java answers this)

If you don't allow globals what are variables the next level down?

In Euphoria I guess they are namespaces.

This problem is hard.

Therefore how do you do scope??

new topic     » goto parent     » topic index » view message » categorize

7. Re: Best Practices

bill said...

Merely a question:

(and I know how Java answers this)

If you don't allow globals what are variables the next level down?

In Euphoria I guess they are namespaces.

This problem is hard.

Therefore how do you do scope??

Euphoria 4.0 introduced two new scopes:

  1. public
  2. export

Basically, these allow symbols to be seen only by files that include the file where the symbol resides. A public symbol can also optionally be seen by files that include the file where the symbol resides. The public scope is expected mainly to be of interest to library developers, where it will allow them to spread their code across multiple files, but still be able to present a simple API to their users that requires only a single include statement.

In general, I recommend using the export scope if you require visibility of a symbol in another file. This requires an explicit include statement in any file that uses the symbol, making dependencies clear and easier to understand.

Euphoria namespaces are used only for resolving which symbol to use. They do not create unique scopes like, say, C++ namespaces do.

Matt

new topic     » goto parent     » topic index » view message » categorize

8. Re: Best Practices

[/quote] heh heh heh, yeah! But at the very least, all of us non-professional programmers will get a chance to see quite a variety of "best practices", and even perhaps some of the reasoning behind some of them, both of which should be interesting, and possibly helpful, too.

Dan [/quote] "should be interesting," - Yes " and possibly helpful, too" - Doubtful

Helpful only to the extent that Every developer has his own idea about what is good for the next level of programmer. Unfortunately they end up giving the application programmer more restriction than help.

I was just looking at another forum of an unrelated language where, you can't click on a list of items and send the clicked text to another window - It is an object oriented rendition of a very nice original language where, programming in DOS in 1992, I was able to do that action very comfortably!

Three cheers for oop!

new topic     » goto parent     » topic index » view message » categorize

9. Re: Best Practices

Vinoba said...
Dan said...

heh heh heh, yeah! But at the very least, all of us non-professional programmers will get a chance to see quite a variety of "best practices", and even perhaps some of the reasoning behind some of them, both of which should be interesting, and possibly helpful, too.

Dan

"should be interesting," - Yes " and possibly helpful, too" - Doubtful

Helpful only to the extent that Every developer has his own idea about what is good for the next level of programmer. Unfortunately they end up giving the application programmer more restriction than help.

I was just looking at another forum of an unrelated language where, you can't click on a list of items and send the clicked text to another window - It is an object oriented rendition of a very nice original language where, programming in DOS in 1992, I was able to do that action very comfortably!

Three cheers for oop!

My real main point was the hope that experienced/professional programmers would share their REASONS for their "best practices" with us, as well as the "best practices" themselves. That way, we could evaluate for ourselves if their "best practices" make sense to us. But so far I don't think I have seen any actual "best practices". I thought "best practices" were some "useful methodologies" in programming, but perhaps I'm mistaken or confused?

Dan

new topic     » goto parent     » topic index » view message » categorize

10. Re: Best Practices

bill said...

Merely a question:

(and I know how Java answers this)

If you don't allow globals what are variables the next level down?

In Euphoria I guess they are namespaces.

This problem is hard.

Therefore how do you do scope??

Euphoria does allow global variables and procedures. Their use is just discouraged in favor of export and public.

new topic     » goto parent     » topic index » view message » categorize

11. Re: Best Practices

DanM said...

My real main point was the hope that experienced/professional programmers would share their REASONS for their "best practices" with us, as well as the "best practices" themselves. That way, we could evaluate for ourselves if their "best practices" make sense to us. But so far I don't think I have seen any actual "best practices". I thought "best practices" were some "useful methodologies" in programming, but perhaps I'm mistaken or confused?

The intent is just that. Now, this thread was to gather some enthusiasm about creating a wiki page to contain best practices. It seems that no one is really interested in it as this thread has very little activity getlost

Jeremy

new topic     » goto parent     » topic index » view message » categorize

12. Re: Best Practices

Hi

It is certainly not as contraversial as I had hoped it would be smile

Chris

new topic     » goto parent     » topic index » view message » categorize

13. Re: Best Practices

I am thinking of writing something about the work I am doing at the moment. It is not something that is "interesing" but rather an inherently difficult problem that many programmers have to deal with.

The problem, simply stated, is how can we do data entry well? IE how can we ensure the names and addresses entered into a database are correct. The straight answer is we can not. But still we must try.

Discussing the problem is valuable because it is open-ended. No single technique works. Many common techniques (Regular expressions, Soundex, Metaphone, Edit distance ..) help with parts of it, other common techniques lose data unnecessarily.

Do you think this might be worth considering? Perhaps database is a bit mundane.

Personally I might say good practice is "try not to write code, good data design is better than pages of (probably buggy) code.

And again I might say "if the code looks verbose, unclear or defensive start again"

new topic     » goto parent     » topic index » view message » categorize

14. Re: Best Practices

bill said...

I am thinking of writing something about the work I am doing at the moment. It is not something that is "interesing" but rather an inherently difficult problem that many programmers have to deal with.

The problem, simply stated, is how can we do data entry well? IE how can we ensure the names and addresses entered into a database are correct. The straight answer is we can not. But still we must try.

I agree...dealing with user input is always difficult. It sounds like an interesting topic that's worth discussing.

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu