For winforms applications I'm wondering what setup code should go in:
MainForm()
as opposed to
MainForm_Load(object sender, EventArgs e)
Are there any best practice guidelines here?
I'm creating a Tetris clone in C++, and I have an enum GameProperty, which is specified as follows:
enum GameProperty {
NUM_OF_TETROMINOES = 7,
NUM_OF_TILES = 4,
TETROMINO_ROTATIONS = 4
};
In my case, I only use these values when looping through a tetromino's tiles, e.g:
for (int i = 0; i < TETROMINO_TILES; i++) { }
Is it under any circumstance considered bad practice to have multiple enumerators with the same value?
Which is a better practice, generally speaking, and why? Under what circumstances would you change your mind?
function foo1(int x) {
int result;
if (x > 5) {
result = 2;
} else {
result = 7;
}
return result;
}
OR
function foo2(int x) {
if (x > 5) {
return 2;
} else {
return 7;
}
}
Some of the tutorials and examples I have seen for developing jQuery plugins tend to return
this.each(function () {
});
at the end of the function that instantiates the plugin but I have yet to see any reasoning behind it, it just seems to be a standard that everyone follows. Can anyone enlighten me as to the reasoning behind this practice?
I have a Django form that is working fine. I'd like to save the data it submits to a CSV file. Is there a "best practice" way to do this?
I need to include blank fields in the CSV file where the user has not filled in a "required=False" field
I like the ease of using @Resource annotation to get a DataSource, but as far as I know, it's not possible to use it in a regular JavaBean. Would it be considered a bad practice if I pass the DataSource object from a servlet to a bean along with the other data to avoid having that lookup code in the bean?
We have a bunch of unit tests which test a lot of webpages and REST API services.
Currently when our tests run it pulls from these pages live but this can take ages to run sometimes, and it also feels like the tests should be testing more of our code - not just relying on them being up and responding (if that makes sense..).
Is it better practice to save a valid api response and with the unit tests load this in during setup?
Thoughts?
Which one of the below 2 code pieces is not calling dispose and therefore is bad practice:
...
using(MD5CryptoServiceProvider p = new MD5CryptoServiceProvider())
{
return p.ComputeHash(...);
}
...
or
...
return new MD5CryptoServiceProvider()).ComputeHash(...);
...
?
iPhone is 480 x 320, iPad is 1024 x 768, iOS 4 is 960 x 640. What is the good practice of managing images for 3 resolutions?
Say the app wallpaper as an example, the iPhone is probably a 50%-reduction of the iOS4 one. But it is also tempting to design one dimension (1024 x 768) for both devices (iPad and iOS 4 phones).
Any suggestions? thanks
Parametrized components work well with the cake pattern as long as you are only interested in a unique component for each typed component's, example:
trait AComponent[T] {
val a:A[T]
class A[T](implicit mf:Manifest[T]) {
println(mf)
}
}
class App extends AComponent[Int] {
val a = new A[Int]()
}
new App
Now my application requires me to inject an A[Int] and an A[String], obviously scala's type system doesn't allow me to extends AComponent twice. What is the common practice in this situation ?
Hi all,
I've been programming in Java for a few courses in the University and I have the following question:
Is it methodologically accepted that every class should implement an interface? Is it considered bad practice not to do so? Can you describe a situation where it's not a good idea to use interfaces?
Thanks.
Is it considered crazy to store common SQL queries for my web app in a database for use in execution? Or is that common practice? Or is it impossible?
My thinking is, this way, I avoid hard-coding SQL into my application files, and add another level of abstraction.
Is this crazy? Is this what a stored procedure is? Or is that something else?
Hi Folks,
I'm curious what would be the best practice to extend the Date constructor.
The problem I'm facing is, that the Internet Explorer (< 7+8) can't parse a date like
new Date('2010-05-11');
I have to admit that this is not a standard method to parse, anyways FireFox and Chrome perform well on that kind of date string.
Now I'm wondering, should I just split/parse/rebuild the string before calling new Date() or is there a more elegant solution ?
For me, I usually make a global class with all members static. All other classes will inherit from this global class.
I wonder if this is a good practice?
Anybody got any suggestions?
When using HTTP/1.1 Pipelining what does the standard say about issuing multiple requests without waiting for each request to complete? What do servers do in practice?
I ask because I once tried writing a client which would issue a batch of GET requests for multiple files and remember getting errors. I wasn't sure if it was due to me incorrectly issuing the GET's or needing to wait for each individual request to finish before issuing the next GET.
I have a base class for some plugin-style stuff, and there are some methods that are absolutely required to be implemented.
I currently declare those in the base class as virtual, for example
public virtual void Save
{
throw new NotImplementedException();
}
and in the descendand I have a
public override void Save()
{
//do stuff
}
Is it a good practice to throw a NotImplementedException there? The descendand classes could for example be the modules for handling different file formats. Thanks
I have written an extension to an existing gem (that is stored in lib) and a corresponding test for my extension.
How could I go about running the gem's tests as well as my own automatically. What is the best practice for this case?
I know how to write program in PHP and implementation of MVC model. but I really want to practice coding like the coding in real world??? I was wondering is there any specific example or book which can show me the tricks or logic and the way professional programmers consider about coding??? Do I need to learn frameworks like Zend ???
Hi I'm new to ASP.NET MVC
and i want to create a class to contain site wide functions for my application
what is the best practice to do this?
where should i create the class ? in what folder?
should i create a new folder?
To help support and anyone who may use one of my applications I tend to log a few things during the application startup.
Currently I log:
Start Time
App Name
App Author
App Version
App Classpath
Current working directory
Java vendor
Java version
Max heap size
Taking into consideration this application may be used / supported by a whole host of people can anyone think of any other vital details which we / others should log for good practice?
What's the best practice of making a variable that would be accessible by almost all classes in a Grails project? Is there a config file that I can use for storage of that data (i.e. application.properties)?
Thanks.
I have a job to develop a website. My client wants it so that there is a header, a menu and for the content a rectangle-like box in which you can scroll the text. So that header and menu don't move but the text in the box does.
It should look like this:
***********header image ***********
menu menu menu menu
--------------
| you ||
| can ||
| scroll in ||
| this box ||
|_____________
Is my only option to implement this an iframe?
Would it be bad practice to use an iframe for this?
hi,
I've a question about how to customize drupal modules avoiding hacks.
Let's say I've downloaded Lightbox2 module and I want to change the javascript file to display differently my lightbox.
At the moment I'm modifying the Lightbox2 module, so I cannot update it anymore, so I know it is not the best practice.
I was wondering if I can customize the javascript file of this module with a hook, and how.
Thanks