conventions

set/get methods in C++

99封情书 提交于 2019-11-29 12:41:13
问题 Java programmers and API seems to favor explicit set/get methods. however I got the impression C++ community frowns upon such practice. If it is so,is there a particular reason (besides more lines of code) why this is so? on the other hand, why does Java community choose to use methods rather than direct access? Thank you 回答1: A well designed class should ideally not have too many gets and sets. In my opinion, too many gets and sets are basically an indication of the fact that someone else

What's the golden code/comment ratio? [closed]

时光怂恿深爱的人放手 提交于 2019-11-29 11:00:37
问题 Is there a code/comment ratio that you consider to be a sign of good (bad) code health? Can you give examples of open source projects that are considered to be well coded and their respective comment ratio? (I realize that no ratio is "true" for every project and there may very well be crappy projects that exhibit this theoretical golden ratio. Still...) 回答1: Comments should be very rare and valuable, almost always expressing the "why" and never the "how" (the exception being when the how is

Conventional Order of CSS properties [closed]

荒凉一梦 提交于 2019-11-29 09:16:30
Is there a standard guideline of what order the CSS properties should be in? This would be to decide if I should use this code p {font-size: 14px; color: purple} or this code instead p {color: purple; font-size: 14px} Edit I am now using The CSS Box Model Convention There is no widely adopted convention. There is no difference between either example, so you should choose the convention you prefer. If you must really satisfy the hobgoblins, choose alphabetical or the order it affects the box model. There is, indeed, no widely agreed-upon convention. I prefer writing Concentric CSS where I list

Is it good practice to use serialize in PHP in order to store data into the DB?

徘徊边缘 提交于 2019-11-29 06:11:20
I came across an interesting comment in php.net about serialize data in order to save it into the DB. It says the following: Please! please! please! DO NOT serialize data and place it into your database. Serialize can be used that way, but that's missing the point of a relational database and the datatypes inherent in your database engine. Doing this makes data in your database non-portable, difficult to read, and can complicate queries. If you want your application to be portable to other languages, like let's say you find that you want to use Java for some portion of your app that it makes

What are the conventional locations for for JSPs, JavaScript, CSS, Images in Maven web projects?

我的梦境 提交于 2019-11-29 01:37:31
I need to convert a traditional J2EE web application into a new Maven web project. In traditional project JSPs are under WebApp/jsps folder, JavaScript & CSS files under WebApp/scripts folder, image under WebApp/images folder, .properties files under WebApp/resources folder. In the Maven project where would each of those file types go? Should I create folders under src/main/webapp such as: src/main/webapp/jsps , src/main/webapp/images , src/main/webapp/resources … etc and copy the files from old project? Or is there any standard structure to follow? Can't Tell Take a look at this article on

Function commenting conventions in R

回眸只為那壹抹淺笑 提交于 2019-11-28 21:18:27
I'm fairly new to R, and I have been defining some of my own functions in script files. I'm intending for others to re-use them later, and I can't find any guides on R function commenting conventions. Is there any way for me to make help("my_function_name") show some help? If not, do I just document the function in the script file, so that someone has to print out (or open the source of) a script to see the comments? Thanks, Hamy The canonical way to document your functions and make them accessible to others is to make a package. In order for your package to pass the build checks, you have to

javascript/DOM event name convention

ぃ、小莉子 提交于 2019-11-28 20:07:00
Hi when I started doing web development, I realized javascript event names were all in lower case with no separators, i.e. "mousedown" , "mouseup" , etc. And when working with the jQuery UI library, I noticed they also use the same convention; i.e. "dropdeactivate" as in the following example javascript $( ".selector" ).on( "dropdeactivate", function( event, ui ) {} ) While this works well for names that are only 2 or 3 words, it is really awful for names with more words on it. Despite of this I followed that convention too when I have to fire custom (synthetic) events that I created, until

CSS Conventions / Code Layout Models [closed]

泪湿孤枕 提交于 2019-11-28 17:51:21
问题 Has there been any attempt and creating a formalized method for organizing CSS code? Before I go and make up my own strategy for keeping things readable, I'm wondering what else is out there. Google hasn't been very helpful, as I'm not entirely sure what terms to search for. I'm thinking more along the lines of indenting/spacing, when to use new lines, naming conventions, etc. Any ideas? 回答1: Natalie Down of ClearLeft fame produced a really great slide show covering this topic and more http:/

Where do you put your Rack middleware files and requires?

蓝咒 提交于 2019-11-28 17:26:05
I'm in the process of refactoring some logic built into a Rails application into middleware, and one annoyance I've run into is a seeming lack of convention for where to put them. Currently I've settled on app/middleware but I could just as easily move it to vendor/middleware or maybe vendor/plugins/middleware ... The biggest problem is having to require the individual files at the top of config/environment.rb require "app/middleware/system_message" require "app/middleware/rack_backstage" or else I get uninitialized constant errors on the config.middleware.use lines. That could get messy very

Large Django application layout

一世执手 提交于 2019-11-28 17:11:30
问题 I am in a team developing a web-based university portal, which will be based on Django. We are still in the exploratory stages, and I am trying to find the best way to lay the project/development environment out. My initial idea is to develop the system as a Django "app", which contains sub-applications to separate out the different parts of the system. The reason I intended to make these "sub" applications is that they would not have any use outside the parent application whatsoever, so