答: Databases usually use one big file for performance reasons.  The DB engine can use its own internal structure and not have to restrict itself to file system limits on block size, buffer size, or fragmentation policies.  I know some systems used to (and possibly still do) provide their own block device drivers.  For those systems, you'd simply hand them a raw disk partition and let the database handle its own storage management, cutting out a level of indirection and speeding up all disk operations.  It's also easier to keep the database in contiguous blocks on disk the fewer files you have to fragment.</p>

Title: Do any database "styles" use discrete files for their tables?

Body:
I've been talking to some people at work who believe some versions of a database store their data in discrete tables. That is to say you might open up a folder and see one file for each table in the database then several other supporting files. They do not have a lot of experience with databases but I have only been working with them for a little over a half year so I am not a canonical source of info either.

I've been touting the benefits of SQL Server over Access (and before this, Access over Excel. Great strides have been made :) ). But, other people were of the impression that the/one of the the benefit(s) of using SQL Server over Access was that all the data was not consolidated down into one file. Yet, SQL Server packs everything into a single .mdf file (plus the log file).

My question is, is there an RDBMS which holds it's data in multiple discrete files instead of one master file? And if the answer is yes, why do it one way over the other?

edit

Thank you everyone for you're answers. This has really helped clarify the whole situation.


问:
What are the disadvantages of automated testing?
There are a number of questions on this site that give plenty of information about the benefits that can be gained from automated testing.  But I didn't see anything that represented the other side of the coin: what are the disadvantages?  Everything in life is a tradeoff and there are no silver bullets, so surely there must be some valid reasons not to do automated testing.  What are they?

Here's a few that I've come up with:

Requires more initial developer time for a given feature

Requires a higher skill level of team members

Increase tooling needs (test runners, frameworks, etc.)

Complex analysis required when a failed test in encountered - is this test obsolete due to my change or is it telling me I made a mistake?

Edit

I should say that I am a huge proponent of automated testing, and I'm not looking to be convinced to do it.  I'm looking to understand what the disadvantages are so when I go to my company to make a case for it I don't look like I'm throwing around the next imaginary silver bullet.

Also, I'm explicity not looking for someone to dispute my examples above.  I am taking as true that there must be some disadvantages (everything has trade-offs) and I want to understand what those are.

答:
It is hard to convince the management/venture capitalist

testautomation increases upfront cost.

testautomation increases time to market.

the benefit of testautomation comes in the mid- and logterm. fierce competition focuses more on shortterm benefits.

see Market Driven Unit Testing for details.

ContentLicense: CC BY-SA 3.0


问:
What's the term describing this system for generating user interfaces?
So, there's this idea, which you already know: Define the layout of your UI by creating a tree of panels. The leaf nodes on the tree are what we used to call 'controls' way back in the day-- the things that the user interacts with, radio buttons and listboxes and such. The internal nodes are mostly concerned with layout; this kind of panel stacks its child panels vertically, that kind puts its children into a grid, etc.

It's COMMON. Most of the UI-generating systems I've seen in the past twenty years are implementations of this, and the ones that aren't borrow from it.

What's the word for this idea?

EDIT: I'm looking for a word, or a phrase, for the pattern I'm describing. It's a big, high-level pattern, and it's become nearly universal. AWT, HTML forms with the controls in table cells, Swing, XAML, Android, and ASP.NET all use it or borrow from it. There's an idea here, on the same level as concepts like "windowing system" or "mesh network." What do we call it?

I suspect that the real answer is, "there's no consensus on a name for it yet." Which would, itself, be really interesting.

答: I usually see it called something similar to a container hierarchy, with the 'controls' being called widgets.


问:
How do you maintain focus when a particular aspect of programming takes 10+ seconds to complete?
I have a very difficult time focusing on what I'm doing (programming-wise) when something (compilation, startup time, etc.) takes more than just a few seconds.  Anecdotally it seems that threshold is about 10 seconds (and I recall reading about study that said the same thing, though I can't find it now).  So what typically happens is I make a change and then run the program to test it.  That takes about 30 seconds, so I start reading something else, and before I know it 20 minutes have passed, and then it takes (if I'm lucky!) another 10+ minutes to deal with the context switch to getting back into programming.

It's not an exaggeration to say that some things that should take me minutes literally take hours to complete.

I'm very curious about what other programmers do to combat this tendency (or if I'm unique and they don't have this tendency?).  Suggestions of any type at all are welcome - anything from "sit on your hands after hitting the compile button", to mental tricks, to "if it takes 30 seconds to start up something to test a change, then something's wrong with your development process!"

答: I suppose we can use the compile time to document the code, code cleanup, aligning the code properly, so that we dont move away from our IDE and still improving the quality of code.</p>


问:
Trying to wrap my head around class structure for domain-specific language
My work is mostly in embedded systems programming in C, and the proper class structure to pull this off eludes me. Currently we communicate via C# and Visual Basic with a large collection of servos, pumps, and sensors via a USB-to-CAN hid device.

Right now, it is quite cumbersome to communicate with the devices.
To read the firmware version of controller number 1 you would use:

```<code>SendCan(Controller,1,ReadFirmwareVersion) or
SendCan(8,1,71)
</code>```

This sends three bytes on the CAN bus: (8,1,71)

Connected to controllers are various sensors.

```<code>SendCan(Controller,1,PassThroughCommand,O2Sensor,2,ReadO2)
</code>```

would tell Controller number 1 to pass a command to O2 Sensor number 2 to read O2 by sending the bytes 8,1,200,16,2,0

I would like to develop a domain-specific language for this setup. Instead of commands issued like they are currently, commands would be written like this:

```<code>Controller1.SendCommand.O2Sensor2.ReadO2
</code>```

to send the bytes 8,1,200,16,0

What's the best way to do this? Some machines have 20 O2 Sensors, others have 5 controllers, so the numbers and types of controllers and sensors, pumps, etc. aren't static.

答:
Your thinking is still too low-level.  You're looking for a better way to say things like "What's the value of O2 detected by O2 Sensor #2?"  But why do you need to know that value?  What are you going to do on the basis of the value?

If you just want a wrapper that's a bit less cumbersome, sure, write that.  But if you want a genuine domain-specific language, you need to start by thinking much more high-level.  You also need to consider making objects that are more capable.

Let's say you need to show an alert if the O2 level is too low.  Simple:

```<code>if (new Controller().O2Sensors[1].Value < 30)
    MessageBox.Show("The canary has died.");
</code>```

Simple, but not good.  To get the most flexible OO design, you should be telling objects what to do rather than querying them:

```<code>new Controller().ShowAlertIfMainOxygenLevelTooLow();
</code>```

Then the Controller itself knows which oxygen sensor is the main one, and it knows what "too low" means.

But what if "too low" differs by environment?  Maybe your controller might be used on a space station, and the O2 environment is richer, and even a small drop indicates trouble.  In that case you'd need to construct your Controller with an appropriate strategy, something like:

```<code>public class Controller
{
    public Controller(IOxygenLevelDetector oxygenLevelDetector)
    {
        [...]
    }
}
</code>```

Your IOxygenLevelDetector interface might have a method that takes the O2 sensor, reads the current O2 level, and returns a bool indicating whether the level is too low, or whether the level is in a success or failure state...whatever makes the most sense to you.  You'd construct your Controller with the appropriate environment:

```<code>new Controller(new SpaceStation())
</code>```

or

```<code>new Controller(new RoomOnEarth())
</code>```

Of course, at some point you're still reading the oxygen level and then doing something.  How do you know when it's the wrong place to do that?  A good rule of thumb is to minimize dots.  Something like this

```<code>new ServiceBoard().Controllers[5].O2Sensors[1].OxygenGauge.Value
</code>```

is too many dots.  The ServiceBoard has too much visibility into the internals of a lot of other objects.  All it should do is go one level: Tell a Controller to do something, and wait for the reply.  The Controller, in turn, should tell an O2Sensor to do something, and should wait for the reply.  In this way, even when you have to make changes, you avoid having them ripple through the entire program.

Body:
Your thinking is still too low-level.  You're looking for a better way to say things like "What's the value of O2 detected by O2 Sensor #2?"  But why do you need to know that value?  What are you going to do on the basis of the value?

If you just want a wrapper that's a bit less cumbersome, sure, write that.  But if you want a genuine domain-specific language, you need to start by thinking much more high-level.  You also need to consider making objects that are more capable.

Let's say you need to show an alert if the O2 level is too low.  Simple:

if (new Controller().O2Sensors[1].Value < 30)
    MessageBox.Show("The canary has died.");

Simple, but not good.  To get the most flexible OO design, you should be telling objects what to do rather than querying them:

new Controller().ShowAlertIfMainOxygenLevelTooLow();

Then the Controller itself knows which oxygen sensor is the main one, and it knows what "too low" means.

But what if "too low" differs by environment?  Maybe your controller might be used on a space station, and the O2 environment is richer, and even a small drop indicates trouble.  In that case you'd need to construct your Controller with an appropriate strategy, something like:

public class Controller
{
    public Controller(IOxygenLevelDetector oxygenLevelDetector)
    {
        [...]
    }
}

Your IOxygenLevelDetector interface might have a method that takes the O2 sensor, reads the current O2 level, and returns a bool indicating whether the level is too low, or whether the level is in a success or failure state...whatever makes the most sense to you.  You'd construct your Controller with the appropriate environment:

new Controller(new SpaceStation())

or

new Controller(new RoomOnEarth())

Of course, at some point you're still reading the oxygen level and then doing something.  How do you know when it's the wrong place to do that?  A good rule of thumb is to minimize dots.  Something like this

new ServiceBoard().Controllers[5].O2Sensors[1].OxygenGauge.Value

is too many dots.  The ServiceBoard has too much visibility into the internals of a lot of other objects.  All it should do is go one level: Tell a Controller to do something, and wait for the reply.  The Controller, in turn, should tell an O2Sensor to do something, and should wait for the reply.  In this way, even when you have to make changes, you avoid having them ripple through the entire program.


问:
Using Clojure instead of Python for scalability (multi-core) reasons, good idea?
After reading http://clojure.org/rationale and other performance comparisons between Clojure and many languages, I started to think that, apart from ease of use, I shouldn't be coding in Python anymore, but in Clojure instead. Actually, I began to feel irresponsible for not learning Clojure, seeing it's benefits.

Does it make sense? Can't I make really efficient use of all cores using a more imperative language like Python, than a Lisp dialect or other functional language? It seems that all the benefits of it come from using immutable data, can't I do just that in Python and have all the benefits?

I once started to learn some Common Lisp, read and did almost all the exercises from a book I borrowed from my university library  (I found it to be pretty good, despite it's low popularity on Amazon). But, after a while, I found myself struggling too much to do some simple things. I think there's somethings that are more imperative in their nature, that makes it difficult to model those things in a functional way.

So is Python as powerful as Clojure for building applications that take advantage of this new multi-core future?

Note that I don't think that using semaphores, lock mechanisms or other similar concurrency mechanism are good alternatives to Clojure's 'automatic' parallelization.

答:
Can't I make really efficient use of all cores using a more imperative language like Python, than a lisp dialect or other functional language?

You definitely can. Depending on the type of the problem (e.g. process clearly separable portions of some big computative task in parallel), it can even be fairly easy. I guess most of the concurrency in the world is still done directly in imperative languages, although the paradigm is shifting towards functional solutions.

Python isn't exactly known for its concurrency capabilities, though. An example of a well-established imperative language with excellent concurrency support is Java.

It seems that all the benefits of it come from using immutable data, can't I do just that in Python and have all the benefits?

The trick with immutable data is that, if you do it with the traditional, simple data structures such as arrays, you'll end up with massive copying and garbage collection, ruining performance. Instead, you want effectively immutable data, which can be implemented with various persistent data structures, as it's done in Clojure under the hood. Such structures could be done in pretty much any language as libraries, but of course direct language support is always nicer.


问:
Which things instantly ring alarm bells when looking at code?
I attended a software craftsmanship event a couple of weeks ago and one of the comments made was "I'm sure we all recognize bad code when we see it" and everyone nodded sagely without further discussion.

This sort of thing always worries me as there's that truism that everyone thinks they're an above average driver. Although I think I can recognize bad code I'd love to learn more about what other people consider to be code smells as it's rarely discussed in detail on people's blogs and only in a handful of books. In particular I think it'd be interesting to hear about anything that's a code smell in one language but not another.

I'll start off with an easy one:

Code in source control that has a high proportion of commented out
  code - why is it there? was it meant
  to be deleted? is it a half finished
  piece of work? maybe it shouldn't have
  been commented out and was only done
  when someone was testing something
  out? Personally I find this sort of
  thing really annoying even if it's just the odd line here and there, but when you see large blocks interspersed with the rest of the code it's totally unacceptable. It's
  also usually an indication that the rest of
  the code is likely to be of dubious
  quality as well.

答:
Comments that say "this is because the design of the froz subsystem is totally borked."

That go on over an entire paragraph.

They explain that the following refactor needs to happen.

But did not do it.

Now, they might have been told they couldn't change it by their boss at the time, because of time or competence issues, but maybe it was because of people being petty.

If a supervisor thinks that j.random. programmer can't do a refactoring, then the supervisor should do it.

Anyway this happens, I know the code was written by a divided team, with possible power politics, and they didn't refactor borked subsystem designs.

True story. It could happen to you.

ContentLicense: CC BY-SA 2.5


答: I usually just try to look for bugs, typos, or ways to improve the style of the code in the meantime. That keeps me looking at the code, but I don't (always) get distracted by something interesting. Also, this!

Title: How do you maintain focus when a particular aspect of programming takes 10+ seconds to complete?

Body:
I have a very difficult time focusing on what I'm doing (programming-wise) when something (compilation, startup time, etc.) takes more than just a few seconds.  Anecdotally it seems that threshold is about 10 seconds (and I recall reading about study that said the same thing, though I can't find it now).  So what typically happens is I make a change and then run the program to test it.  That takes about 30 seconds, so I start reading something else, and before I know it 20 minutes have passed, and then it takes (if I'm lucky!) another 10+ minutes to deal with the context switch to getting back into programming.

It's not an exaggeration to say that some things that should take me minutes literally take hours to complete.

I'm very curious about what other programmers do to combat this tendency (or if I'm unique and they don't have this tendency?).  Suggestions of any type at all are welcome - anything from "sit on your hands after hitting the compile button", to mental tricks, to "if it takes 30 seconds to start up something to test a change, then something's wrong with your development process!"


答: The generic term for such a tool is "GUI Builder". As you've clearly noted, that these tools can range from being completely drag-n-drop WYSIWYG, to something that is more expert-programmer oriented, where the design approach isn't exactly WYSIWYG, but represented using a hierarchical relationship of bunch of widgets (example XUL) in a more textual / programmatic form.</p>

Title: What's the term describing this system for generating user interfaces?

Body:
So, there's this idea, which you already know: Define the layout of your UI by creating a tree of panels. The leaf nodes on the tree are what we used to call 'controls' way back in the day-- the things that the user interacts with, radio buttons and listboxes and such. The internal nodes are mostly concerned with layout; this kind of panel stacks its child panels vertically, that kind puts its children into a grid, etc.

It's COMMON. Most of the UI-generating systems I've seen in the past twenty years are implementations of this, and the ones that aren't borrow from it.

What's the word for this idea?

EDIT: I'm looking for a word, or a phrase, for the pattern I'm describing. It's a big, high-level pattern, and it's become nearly universal. AWT, HTML forms with the controls in table cells, Swing, XAML, Android, and ASP.NET all use it or borrow from it. There's an idea here, on the same level as concepts like "windowing system" or "mesh network." What do we call it?

I suspect that the real answer is, "there's no consensus on a name for it yet." Which would, itself, be really interesting.


答:
The guys here gave really excellent answers.

Concurrent programming is usually hard because of "sharing state". Functional programming may not be the ultimate answer but it surely make it doable without losing your hair.

Clojure for sure is a viable option but even with its excellent concurrency tools, you might need to build something else.  Check Prismatic for an example:

Our backend language choice is Clojure on the JVM. There are other great functional languages on the JVM, like Scala, but what we like about Clojure is that it has a small, simple core focused around processing data represented in its excellent set of persistent data structures (or their mutable java.util equivalents, when the need strikes). While we make heavy use of the core of Clojure, we don't use its concurrency primitives (atoms, refs, STM, etc.) because a function like pmap doesn't have enough fine grained control for our needs. We opt instead to build our own concurrency abstractions in Clojure on top of the outstanding java.util.concurrent package.

If you really want to go wild, then check also Julia Programming Language.

Julia does not impose any particular style of parallelism on the user. Instead, it provides a number of key building blocks for distributed computation, making it flexible enough to support a number of styles of parallelism, and allowing users to add more.

Title: Using Clojure instead of Python for scalability (multi-core) reasons, good idea?

Body:
After reading http://clojure.org/rationale and other performance comparisons between Clojure and many languages, I started to think that, apart from ease of use, I shouldn't be coding in Python anymore, but in Clojure instead. Actually, I began to feel irresponsible for not learning Clojure, seeing it's benefits.

Does it make sense? Can't I make really efficient use of all cores using a more imperative language like Python, than a Lisp dialect or other functional language? It seems that all the benefits of it come from using immutable data, can't I do just that in Python and have all the benefits?

I once started to learn some Common Lisp, read and did almost all the exercises from a book I borrowed from my university library  (I found it to be pretty good, despite it's low popularity on Amazon). But, after a while, I found myself struggling too much to do some simple things. I think there's somethings that are more imperative in their nature, that makes it difficult to model those things in a functional way.

So is Python as powerful as Clojure for building applications that take advantage of this new multi-core future?

Note that I don't think that using semaphores, lock mechanisms or other similar concurrency mechanism are good alternatives to Clojure's 'automatic' parallelization.


答: They way most folks implement fluent-style interfaces is to first implement a standard object sort of interface then wrap things in interfaces with extension methods to get to fluent. </p>

Title: Trying to wrap my head around class structure for domain-specific language

Body:
My work is mostly in embedded systems programming in C, and the proper class structure to pull this off eludes me. Currently we communicate via C# and Visual Basic with a large collection of servos, pumps, and sensors via a USB-to-CAN hid device.

Right now, it is quite cumbersome to communicate with the devices.
To read the firmware version of controller number 1 you would use:

```<code>SendCan(Controller,1,ReadFirmwareVersion) or
SendCan(8,1,71)
</code>```

This sends three bytes on the CAN bus: (8,1,71)

Connected to controllers are various sensors.

```<code>SendCan(Controller,1,PassThroughCommand,O2Sensor,2,ReadO2)
</code>```

would tell Controller number 1 to pass a command to O2 Sensor number 2 to read O2 by sending the bytes 8,1,200,16,2,0

I would like to develop a domain-specific language for this setup. Instead of commands issued like they are currently, commands would be written like this:

```<code>Controller1.SendCommand.O2Sensor2.ReadO2
</code>```

to send the bytes 8,1,200,16,0

What's the best way to do this? Some machines have 20 O2 Sensors, others have 5 controllers, so the numbers and types of controllers and sensors, pumps, etc. aren't static.


答: It's conceivable you've got a bit of ADHD. Lots of people do. Coping mechanisms are as given in the other answers (or possibly medication).</p>


问:
What to do if a co-worker is editing your code just to change the appearance?
What should you do, if a co-worker is editing your code?

Without the purpose of adding functionality or fixing bugs, just to change how it looks...

答:
this is a thought I saw on internet talking about refactoring and maybe explain why would someone touch your code to make it better:

Why?

There are two main reasons to refactor:

To improve the code/design before
building on it’s top: It’s really
hard to come up with good code on
the first attempt. The first try to
implement any initial design will
show us that we misinterpreted or
forgot some logic.

To adapt to changes in the
requirements. Change happens in the
software development; to be
responsive to change is better to
have a good code base. We have two
options for both scenarios, path the
code or refactor it. Patching the
code will lead us to unmaintainable
code, and will increase our
technical debt, it’s always better
to refactor.

When?

The sooner the better as is easier.

faster and less risky to refactor over a recently refactored code rather than waiting to refactor for the code to be almost completed.

What?

All the code and all the design are candidates for refactoring.

An exception for not refactoring something could be a working piece of code which is quality is low, but due to be close to a deadline, we prefer to keep our technical debt rather than risking the planification.

You just have to let him do his best, if it would be great for both and save your time in future!

cheers


问:
Visual Basic link to SQL output to Word
I am in need of some advice/references. I am currently trying to develop a legal document interface. There are certain fields in which I need to query out of my sql db and have those fields output into a document that can be printed. I am trying to develop a user interface where people can enter fields that will output to a document template but at the same time I need the template to be able to pull data from the SQL database. This is the reason why I think that VB might be my best choice and because it is one of the only OOP languages I am familiar with presently. Does anyone know that best way to be able to handle this type of job?

I know that you can use VBA within MS Word and have the form output variables to a word template. But, is there a way to have the word document also pull information from the SQL db? Is the best option to use VB linked to SQL and run queries to get the information from the database and then have it output to a for within VB? Is it possible for VB to be linked to a SQL db and output variables and SQL fields to a Word Template?

I have looked into Mail Merge and I see that it allows users to pull data from an Access query but I dont think it would be easy to automate and it seems that users would need to have an advanced knowledge of MS Word and Access to handle this. I am not finding much useful information online so I came here.

Any advice or references would be greatly appreciated. If there is a better way please let me know.

答:
If you are going the VBA route, connecting to an SQL database and pulling some information from there is easy. You can use classic "ADO", here

http://www.vbexplorer.com/VBExplorer/vb_feature/june2000/Database_Beginner_ADO_DAO.asp

you will find some examples. Of course, when you have to design a dialog based user interface, I would prefer to use VB.NET instead (together with automation, just like the others suggested.)

Title: Visual Basic link to SQL output to Word


问:
Is re-defing idiomatic in clojure?
Simple example:

```<code>(def ticks 0)
(defn run-iteration []
  (def ticks (inc ticks)))
</code>```

Though the usual case involves things that don't change more than once every several hundred ms.

How to do this idiomatically?

Edit: and why is the idiomatic way idiomatic, and why is it good?

答:
What you really want is one of clojure's mutable reference types, for your example, I would use an atom, like this:

```<code>(def ticks (atom 0))
(defn ++ticks []
  (swap! ticks inc))
</code>```

and to get the value, @ticks

http://clojure.org/atoms

Don't use a def for this, in fact the only sane reasons you can redef is to enable development at the repl or hot code reloading.

The above solution is idiomatic as clojure has a philosophy of maximal immutability and controlled mutability.  An atom is the simplest form of controlled mutability provided by clojure.  This solution is ready for use by multiple threads, and is appropriate for use by a single thread, without you having to think about it too much.  That's the clojure way.

Title: Is re-defing idiomatic in clojure?

Body:
What you really want is one of clojure's mutable reference types, for your example, I would use an atom, like this:

(def ticks (atom 0))
(defn ++ticks []
  (swap! ticks inc))

and to get the value, @ticks

http://clojure.org/atoms

Don't use a def for this, in fact the only sane reasons you can redef is to enable development at the repl or hot code reloading.

The above solution is idiomatic as clojure has a philosophy of maximal immutability and controlled mutability.  An atom is the simplest form of controlled mutability provided by clojure.  This solution is ready for use by multiple threads, and is appropriate for use by a single thread, without you having to think about it too much.  That's the clojure way.


问:
How were some language communities (eg, Ruby and Python) able to prevent fragmentation while others (eg, Lisp or ML) were not?
The term "Lisp" (or "Lisp-like") is an umbrella for lots of different languages, such as Common Lisp, Scheme, and Arc. There is similar fragmentation in other language communities, like in ML.

However, Ruby and Python have both managed to avoid this fate, where innovation occurred more on the implementation (like PyPy or YARV) instead of making changes to the language itself.

Did the Ruby and Python communities do something special to prevent language fragmentation?

答:
One likely factor is simply age. Lisp and ML are a lot older than Python and Ruby:

Lisp: 1958

ML: 1973

Python: 1991

Ruby: 1995

Lisp and ML have obviously seen much greater change in hardware capabilities, more trends in computer science, and a great many more Ph.D students looking for something to work on.


答:
Don't forget to weigh the culture driving a language's development

I would also weight the fact that development on python/php is actively done in public. You have one group of individuals nailing down a standard specification that is freely available to anybody/everybody.

Much like the W3C does with the HTML/CSS standard. You have a small group of motivated individuals who control the finer details of what the language is designed to accomplish. Everything goes into a clearly defined specification before it's released to the public.

OTOH, languages like LISP are forked behind closed doors by professors or other individuals that genuinely believe that their perspective on the 'best use' of the language is right. They may be simultaneously right and wrong at the same time because some implementations are great at certain things; while none are the best at everything.

That's not necessarily a bad thing because diversity breeds innovation. Languages like LISP are, and will remain great languages for learning and research because they push the boundaries of understanding.

But the qualities that make an environment good for innovation aren't necessarily beneficial for stability; conversely, the qualities that make an environment good for stability aren't necessarily good for creativity.

When development is based on active collaboration, sometimes individuals are forced to concede for the benefit of the greater whole. Bad for research/good for consistency.

The fact is, we're still living in the wild-west of programming language development. The problem of designing the 'ideal language' is so great that, despite monumental efforts, nobody has come close to solving it.

In the research/academia sector, there's still a lot of room for improvement and innovation. In the commercial sector, where there is an exponential growth of software being use in practical applications and the driving force is simplicity and consistency.

Some languages specialize in the former, some specialize in the latter. Those that try to specialize in both usually don't do either very well and die off.

By both, I'm referring to monolithic languages like VB/C#/Java. It's too early to say but I'd like to see what C# and Python look like in 10 years. At the current pace C# is growing functionality and inconsistency at a rate that makes it look pretty grim. Even with great documentation, it's just too much of a pain to remember all the subtle details and quirks included in the language. It's great for a single developer but as soon as you throw in more developers with unique styles, inconsistency in the codebase grows, quality suffers, and nobody wins. I think there's a lot to be learned from the difficulties Perl presents in a production environment.

Title: How were some language communities (eg, Ruby and Python) able to prevent fragmentation while others (eg, Lisp or ML) were not?

Body:
The term "Lisp" (or "Lisp-like") is an umbrella for lots of different languages, such as Common Lisp, Scheme, and Arc. There is similar fragmentation in other language communities, like in ML.

However, Ruby and Python have both managed to avoid this fate, where innovation occurred more on the implementation (like PyPy or YARV) instead of making changes to the language itself.

Did the Ruby and Python communities do something special to prevent language fragmentation?


问:
Starting an HTML canvas game with no graphics skills
I want to do some hobby game development, but I have some unfortunate handicaps that have me stuck in indecision; I have no artistic talent, and I also have no experience with 3D graphics.  But this is just a hobby project that might not go anywhere, so I want to develop the stuff I care about; if the game shows good potential, my graphic "stubs" can be replaced with something more sophisticated.  I do, however, want my graphics engine to render something approximate to the end goal.

The game is tile-based, with each tile being a square.  Each tile also has an elevation.  My target platform (subject to modification) is JavaScript rendering to the HTML 5 canvas, either with a 2D or WebGL context.

My question to those of you with game development experience is whether it's easier to develop an isometric game using a 2D graphics engine and sprites or a 3D game using rudimentary 3D primitives and basic textures?  I realize that there are limitations to isometric projection, but if it makes developing my throwaway graphics engine easier, I'm OK with the visual warts that would be introduced.  Or is representing a 3D world with an actual 3D engine easier?

答: 2D isometric sprites based game is significantly easier than 3D in HTML canvas.</p>


问:
Developing assistance tools for games, is it legal against the game creator?
Imagine if for a realtime strategy game, for reaserch and some fun a tool has been made which monitors the minimap of the game and warns the user if the enemy movement is being detected.

Does selling and/or distributing such stuff have legal issues, against the game creators ToS or such (Considering its usage in multiplayer)?

答:
This is quite dependent on the game's terms of use (they might forbid those tools).

A random sampling says:

Blizzard says:

You agree that you will not, under any circumstances:
[...]
use cheats, automation software (bots), hacks, mods or any other unauthorized third-party software designed to modify the World of Warcraft experience;

EA says:

You may violate the Terms of Service if, as determined by EA in its sole discretion, you: [...]

Promote, encourage or take part in any activity involving hacking, cracking, phishing, taking advantage of exploits or cheats and/or distribution of counterfeit software and/or virtual currency/items.

Zynga says:

CHEATING AND HACKING - You agree that you will not, under any circumstances:

[...]

d. Use cheats, exploits, automation software, bots, hacks, mods or any unauthorized third party software designed to modify or interfere with the Service or any Zynga game experience;

Even if the game's terms of use don't allow those tools, there's the subjective aspect: some gamers will consider those tools unethical and look down on anybody who uses them.

As stated on a comment, while in singleplayer games they'd be OK, in multiplayer games they will most likely seen as cheating.


问:
Clojure: vars, atoms, and refs (oh my)
also: defs, java fields, agents

The clojure website has documentation for these concepts:

Vars

Atoms

Refs

Agents

I understand the words, but I don't conceptually get the purpose / meaning of these. When should I / how can I know when to use them?

答:
Use Refs for synchronous, coordinated and shared changes.

Use Agents for asynchronous, independent and shared changes.

Use Atoms for synchronous, independent and shared changes.

Use Vars for isolated changes.

EDIT

The links you posted are highly important to read, however I also recommends this: Software Transactional Memory

Keep in mind that aborted transactions will be replayed. What does this mean?

It means that the code inside dosync could be executed a couple of times, so you need to be careful the code should be side effects free.

One use of agents is to have a controlled side effects. Consider this:

```<code>(dosync
  (send log-agent message args)
  (alter reference function))
</code>```

The STM will hold all of the actions needed to be sent to agents until succeed.

What is difference between atoms and agents?

Updates to agents will happen asynchronously at some point of the future, updates to atoms will happened immediately.

Atoms and agents don't need to run inside a transaction, refs should be (coordinated changes, remember?)

Title: Clojure: vars, atoms, and refs (oh my)

Body:
Use Refs for synchronous, coordinated and shared changes.

Use Agents for asynchronous, independent and shared changes.

Use Atoms for synchronous, independent and shared changes.

Use Vars for isolated changes.

EDIT

The links you posted are highly important to read, however I also recommends this: Software Transactional Memory

Keep in mind that aborted transactions will be replayed. What does this mean?

It means that the code inside dosync could be executed a couple of times, so you need to be careful the code should be side effects free.

One use of agents is to have a controlled side effects. Consider this:

(dosync
  (send log-agent message args)
  (alter reference function))

The STM will hold all of the actions needed to be sent to agents until succeed.

What is difference between atoms and agents?

Updates to agents will happen asynchronously at some point of the future, updates to atoms will happened immediately.

Atoms and agents don't need to run inside a transaction, refs should be (coordinated changes, remember?)


问:
Detect frameworks and/or CMS utilized on websites in Firefox
I'm redesigning the website for my academic library and am examining other sites to determine to identify the technologies used. Things like:

Web frameworks

Javascript frameworks

Server-side technology

Content management system

Now I've had some real success in Firefox using plugins like Wappalyzer, Firebug, and the DOM Inspector. But some sites just don't display any of the info. I'm looking for using these tools, especially it seems it an enterprise-level CMS is being used.

Does anyone know of any other tools to detect this kind of data? Also with Firebug & the DOM Inspector, there is a lot of info. displayed and I wondered if there was a way to derive the presence of server-side technologies, CMS's, etc. within certain elements of a web page?

Also, if this question is more relevant to another Stack Exchange site, please let me know and I'll post it there instead.

Much thanks,

Jason

答:
As mentioned above, it's impossible to tell server side frameworks, but there's plenty of tools for CSS, JS, and guessing when it comes to Server Side.  Here's a superb list of tools:

The best way is to find out who developed the website.  Often times on their website, they'll list their technologies/frameworks and you can always ask.

If that doesn't work, here's a list of tools that'll get you a long way in the right direction from a Stack Overflow Thread

I like starting with Built With as it doesn't require an install and is pretty thorough right off the bat.

As mentioned in several places, if you look at the headers and/or source code, there's often clues to what was used.

If includes have "wp-content" or "wp-includes" anywhere in the url, it's wordpress.  Sometimes it'll have a theme name in every url you can lookup.

Someone mentioned looking at the cookies for clues.

That should get you a long way in the right direction anyway.


答: To add to Renan's response, deliberately violating the ToS (assuming you agree to it) is fraud.</p>

Title: Developing assistance tools for games, is it legal against the game creator?

Body:
Imagine if for a realtime strategy game, for reaserch and some fun a tool has been made which monitors the minimap of the game and warns the user if the enemy movement is being detected.

Does selling and/or distributing such stuff have legal issues, against the game creators ToS or such (Considering its usage in multiplayer)?


问:
C++ equivalent to the Sun Java Language Specification and JVM Specification?
Does C++ have an "official" language specification document, similar to the Sun/Oracle:

http://docs.oracle.com/javase/specs/#6.6.1

答:
I think the closest to official are the ISO/IEC 14882 standards (warning: paywall, you will not be able to download the standard without a subscription).

ISO/IEC 14882:2011 specifies requirements for implementations of the C++ programming language. The first such requirement is that they implement the language, and so ISO/IEC 14882:2011 also defines C++. Other requirements and relaxations of the first requirement appear at various places within ISO/IEC 14882:2011.

However, as stated in a comment below, the drafts of those standards are available for free, such as here.


答:
Does it really matter what technology they used? Pretty much all good CMSs let you build good websites. If you are looking at other sites, better concentrate on:

What you like and dislike about them

How their information is organised

How their sites look on mobiles and other devcies

Specific features that make them unique, if any,

It really doesn't matter what the technology stack is.

But if you really want to know you can probably guess that it's Wordpress, since that powers about 20% of new US sites. And you can't really go wrong with choosing Wordpress unless you have some very specific needs.

Title: Detect frameworks and/or CMS utilized on websites in Firefox

Body:
I'm redesigning the website for my academic library and am examining other sites to determine to identify the technologies used. Things like:

Web frameworks

Javascript frameworks

Server-side technology

Content management system

Now I've had some real success in Firefox using plugins like Wappalyzer, Firebug, and the DOM Inspector. But some sites just don't display any of the info. I'm looking for using these tools, especially it seems it an enterprise-level CMS is being used.

Does anyone know of any other tools to detect this kind of data? Also with Firebug & the DOM Inspector, there is a lot of info. displayed and I wondered if there was a way to derive the presence of server-side technologies, CMS's, etc. within certain elements of a web page?

Also, if this question is more relevant to another Stack Exchange site, please let me know and I'll post it there instead.

Much thanks,

Jason


问:
When to use PHP or ASP.NET?
I have worked extensively in developing web applications using PHP and ASP.NET, but one of the questions that I'm constantly asked by customers is whether to move forward with a php website or an asp.net website.

So naturally the first thing that comes to mind is to answer the question like this:

PHP is open-source and ASP.NET is from Microsoft.

Usually after something like that is said the customer has a blank look on there face. Apparently the fact that one is open source and the other isn't doesn't really faze them. And for good reason, because when I first heard it, it really doesn't tell me much.

I know from working with both that each have their differences when it comes to developing websites.

My question is what are differences between ASP.NET and PHP as far as

Features

Security

Extendability

Frameworks

Average Development Time

I am trying to compile a list of facts to be able to compare with the customer so that an informed choice on the appropriate development platform can be made.

答: .net controls are much nicer that what you can find with a PhP platform. Look at Infragistics for instance, what is the equivalent for a LAMP ?</p>

Title: When to use PHP or ASP.NET?


答:
The C++ specification can be bought from ISO for the equivalent around $300 US. The BSI imprinted version is a bit more pricey -- around $750US if memory serves.

Fortunately, the ANSI has priced their version a bit more reasonably -- $30US.

While the truly official version isn't free, if you want something really close that is free, the standard committee's web site has a draft from shortly before standardization, and another from just after, with a few typos fixed and such.

Title: C++ equivalent to the Sun Java Language Specification and JVM Specification?

Body:
Does C++ have an "official" language specification document, similar to the Sun/Oracle:

http://docs.oracle.com/javase/specs/#6.6.1


答:
You have the following options (at least):

1-Pure VBA

2-.NET application with VBA automation

3-.NET application without VBA automation

The problem with all 3 approaches is that you may need to re-work the code if the template changes.

The problems with 1 and 2 are:
- User must have Office installed

It is not trivial to deploy office macros unless you know what you are doing well

VBA does not have fancy GUI

What if Office version is upgraded or if not all users are using the same version?

Option 2 is specifically sensitive to office libraries availability on the user's machine and uses COM which is something you want to avoid if you can.

Option 3 could be used by obtaining a 3rd party tool that could generate MS-Word document without the need for the user to have MS-Office installed. Depending on the complexity of the output document, you could even use a free report writer to display the resulting document as a report or save it as an MS-Word document. Almost all report writers can do that.
You could define your input text and format either in a MS-Word document or as a separate application-specific file using HTML, XML, etc.).

This option provides an easier installation and distribution but is more complex to develop and may cost you some money.

The advantages of this is that it does not depend on MS-Office version installed much. MS has always been compatible with its older file formats.

Title: Visual Basic link to SQL output to Word

Body:
I am in need of some advice/references. I am currently trying to develop a legal document interface. There are certain fields in which I need to query out of my sql db and have those fields output into a document that can be printed. I am trying to develop a user interface where people can enter fields that will output to a document template but at the same time I need the template to be able to pull data from the SQL database. This is the reason why I think that VB might be my best choice and because it is one of the only OOP languages I am familiar with presently. Does anyone know that best way to be able to handle this type of job?

I know that you can use VBA within MS Word and have the form output variables to a word template. But, is there a way to have the word document also pull information from the SQL db? Is the best option to use VB linked to SQL and run queries to get the information from the database and then have it output to a for within VB? Is it possible for VB to be linked to a SQL db and output variables and SQL fields to a Word Template?

I have looked into Mail Merge and I see that it allows users to pull data from an Access query but I dont think it would be easy to automate and it seems that users would need to have an advanced knowledge of MS Word and Access to handle this. I am not finding much useful information online so I came here.

Any advice or references would be greatly appreciated. If there is a better way please let me know.


问:
How do I balance program CPU reverse compatibility whist still being able to use cutting edge features?
As I learn more about C and C++ I'm starting to wonder: How can a compiler use newer features of processors without limiting it just to people with, for example, Intel Core i7's?

Think about it: new processors come out every year with lots of new technologies. However you can't just only target them since a significant portion of the market will not upgrade to the latest and greatest processors for a long time.

I'm more or less wondering how this is handled in general by C and C++ devs and compilers. Do compilers make code similar to if SSE is supported, do this using it, else do that using the slower way or do developers have to implement their algorithm twice, or what?

More or less how do you release software that takes advantage of newer processor technologies while still keeping a low common denominator?

答: Agner Fogg's C++ Optimization Manual contains an extensive section (page 124: Section 13: "Making critical code in multiple versions for different instruction sets") on ways of dealing with this problem.  (That document is one of a set.)</p>


问:
How do I start correctly in building database classes in c#?
I am new in C# programming and in OOP. I need to dive into web applications for my company, and I need to do it fast and correct.

So even that I know ASP.NET MVC is the way to go, I want to start with some simple applications with ASP.NET Webforms and then advance to MVC logic.

Also regarding my db classes: I plan to create common database classes in order to be able to use them either from WinForms or ASP.NET applications.

I also know that the way to go is to learn about ORM and EF. BUT I also want to start from where I am feeling comfortable and that is the traditional ADO.NET way.

So about my Data Access Layer classes:

Should I return my results in datasets or arraylists/lists?

Should my methods do their own connect/disconnect from the db, or have separate methods and let the application maintain the connection?

答:
INMO the idea to give up EF and other ORMs is not a very good one if you are intending to produce a professional production application today that will be used as part of a larger project. This was viable option in the early days of .NET.

The advantages of using EF/ORM are so many and if you program for living, you will probably have to learn about it anyway, so do it now if you can.

Datasets are easier to use and program with but some people hate them. If you are not strong in OO, datasets will help you go quicker but this approach is usually criticized.

Connection to the database should be centralized and hidden from client code. It is common to use the Factory pattern to create objects. You start a transaction by establishing a connection and then close it. Closing a connection in code does not always physically close the connection, instead it returns it the pool of available connections. So yes, you issue close implicitly or explicitly in your methods code.

I would like to recommend to you to spend some time with a book that takes an application from start to end to see your questions answered in more details. There are several concepts that you need to be aware of to get your application performing well and secure. Also, differentiate between training projects and production projects. Web development is not trivial and it takes sometime to learn and master.


问:
What techniques help retain programming knowledge?
How do you remember programming related stuff? Have you had the feeling that you've encountered the error you have before you right now, a few years ago and you could swear you knew the cause then but now you've forgotten it?

Did you work with the xsl's string parsing some time ago but now you can't remember exactly which are the string functions altogether from xsl and you have to start from scratch? Or perhaps you forget about some feature from Apache Commons like "filtering a collection by some predicate" that you surely used in the past.

So how do you do it? I tried having a blog but when I develop apps, I never find the time to update the blog or write about my experiences. Also, using a wiki is a nice thing but then I found it difficult to keep a clean separation between them since many times I needed to change a blog post to add new information about that topic. This made me think that I actually should have put this topic in the wiki instead of the blog.

Do you have any systems that help you remember about your programming experience? What's your setup?

答:
You must be balanced between memory and "storage"..If you rely too much or for wrong things in memory, == problem, if you rely too much on storing everything == useless.

My rules:

-Do not over beautify! write the important stuff even if the font size varies in your doc :)

-Do not over orginize. Convince yourself that orginizing your thoughts doenst need a 10-level tree structure

-Spent TIME in finding what to record. you may find 5 solutions for the same problem. the moment you write them ALL down you loose. Write down 1-2 that REALLY help you. do NOT let yourself tell you that you dont have time for this now. Its rather strange but it applies: "Spent time to get time"

I dont like putting these things in some "product" because i want to be sure that it will exist 20 years later and i dont want to migrate myself to various platforms..

So what to do?

Anything that you can get the info with minimum effort.

For example install phpBB and write to your self. you get search functionality out of the box, its free and you can have data extracted with simple SQL statements and put them in files. you can have a cronjob exporting your thoughts in files for archiving. So if you ever need to put them in another system you are ready with minimum effort.

Another problem is that nobody guarantees that the links you find will work tommorow (imagine 5 years later). So try to duplicate the info:

-Download the video with some browser extention and attach it for example to your phpBB post (or wordpress or whatever).

Face it: you are a programmer and you make apps for other people. Make a simple one for yourself and become YOUR best client.

my 2c


答:
Generally speaking, 2D and pseudo-3D (such as isometric and other axonometric projections) is much easier than 3D in many regards.

First of all, 3D game logic is way more complex than 2D - many simple techniques for things like collision detection and physics simply don't work in 3D, and even for those that do, wrapping your head around what happens is significantly harder in 3D. (After all, we humans are built for living on a relatively flat surface, so our brains are inherently 2.5D).

Another problem is that 3D artwork is a lot more complex. With 2D graphics, you only have one viewpoint to consider; if your sprite looks good in the editor, it will look good in the game. In 3D, you are typically using mesh models, and they are dynamically shaded, and both the viewpoint and the light direction can be virtually anything. Your models still need to look convincing at all times, which makes creating them much harder than 2D sprites.

And then there are the technical constraints of the web:

WebGL is not yet universally available; getting it to run at all involves quite some black magic on some platforms, and even if it does work, performance characteristics are quite unreliable. 2D canvas, by contrast, works out-of-the box on any recent browser and OS. Doing 3D graphics on a 2D canvas, while perfectly possible, requires considerable trickery to get partial occlusion right (either clipping polygons against each other yourself, or using the sub-optimal Painter's Algorithm), and textured primitives are pretty much impossible. You'll also have to write all the lighting code yourself. A typical isometric graphics engine, however, is perfectly doable on a 2D canvas.

Javascript is single-threaded, and wasn't meant to provide accurate low-granularity timing, which you need for smooth graphics. Hickups in animation smoothness are much more tolerable in a 2D game than in 3D, unless the 3D scene is mostly static and doesn't involve a moving camera.

Title: Starting an HTML canvas game with no graphics skills

Body:
I want to do some hobby game development, but I have some unfortunate handicaps that have me stuck in indecision; I have no artistic talent, and I also have no experience with 3D graphics.  But this is just a hobby project that might not go anywhere, so I want to develop the stuff I care about; if the game shows good potential, my graphic "stubs" can be replaced with something more sophisticated.  I do, however, want my graphics engine to render something approximate to the end goal.

The game is tile-based, with each tile being a square.  Each tile also has an elevation.  My target platform (subject to modification) is JavaScript rendering to the HTML 5 canvas, either with a 2D or WebGL context.

My question to those of you with game development experience is whether it's easier to develop an isometric game using a 2D graphics engine and sprites or a 3D game using rudimentary 3D primitives and basic textures?  I realize that there are limitations to isometric projection, but if it makes developing my throwaway graphics engine easier, I'm OK with the visual warts that would be introduced.  Or is representing a 3D world with an actual 3D engine easier?


问:
XML: Multiple roots + text content outside the root. Does anyone do it?
I have another one of those "is it done in XML" questions (my last one about xml comments hasn't been answered if anyone has a good explanation)

I was just wondering if anyone, anywhere would:

Use multiple root elements in an XML document

Put text content outside of a root element

W3C discourages these practices, Javascript's DOMParser doesn't even allow these cases, and I can't think of one sane reason to do either of these things. However, I know how bizarre some implementations of XML have been, so I wouldn't be surprised.

Does anyone have any real world examples where this would be done? I will also accept an answer that specifies if other mainstream parsers allow doing either of these.

答:
As per the standard, an XML document must have exactly one root element in order to be well formed XML. Any parser that accepts otherwise is wrong, and any XML document that is structured any different is not in fact an XML document.

It is not merely discouraged by W3C, but simply against the standard.


问:
Recommended reading for (Object Oriented) application design architecture?

Possible Duplicate:

  Best books on the theory and practice of software architecture?

In life it doesnt matter if you do one thing for 15 years. You will end up waking one day and asking stuff that are equal to  "how do i walk?" :)

My specific question is that as a new entrant to C# and OOP i am stepping into many little "details" that need to be addressed.

Written a lot of code in VB.NET / cobol / simple php e.t.c surely does not help much into the OOP world...

So , even after reading entry level books for C# and watching some videos i recently found out about the "factory model design" for applications.

I would appreciate if any of you guys recomment some reading on application design architecture for further reading...

答:
Object Oriented Design:
Object-Oriented Design
Is one of my favorite books on the topic, a bit dense, but otherwise
great. Average of 4.5 Star Reviews.

Object-Oriented Thought Process, The (3rd Edition):
Object-Oriented Thought Process, The (3rd Edition). Is a more recently released option…also very good.

Python 3 Object Oriented Programming:
Python 3 Object Oriented Programming


问:
How does using a LGPL gem affect my MIT licensed application?
I am developing an open source ruby application under the MIT license.  I am using this license because I don't want to place any restrictions on the users of the application.  Also I can actually read and understand this license.

I recently started using another ruby gem in my project (require "somegem").  This ruby gem is under the LGPL license.

Do I have to change anything about my project because I am using this other ruby gem that is licensed with LGPL?  My project does not contain the source code for the other gem and it is not shipped with my project.  It is simply listed as a dependency so that ruby gems will install it and my project will call into it from my code.

Additionally, it would be helpful to know if there are any licenses I need to "watch out for" because using them would affect the license of my project.

There are some other post about this topic but phrased in different ways.  Since I find this license stuff tricky I am hoping to get a answer directed at my situation.

Thank you,

Corsen

答:
Do I have to change anything about my project because I am using this other ruby gem that is licensed with LGPL? My project does not contain the source code for the other gem and it is not shipped with my project. It is simply listed as a dependency so that ruby gems will install it and my project will call into it from my code.

The LGPL'ed software is a dependency of your software. So it actually is part of your software. The LGPL allows to be used from non-free software (while MIT is even free software), so being a dependency is not a blocker.

However as it's a dependency you need to offer the source-code of it if you distribute your software. I have no clue if the require mechanism within ruby always provides sources as well. If so I'd say that you already distribute with sources. If not, you need to take care that for every version of that gem that you require with your software you offer sources for.

You probably should take care of sources anyway because it might be that the third-party project (the gem) will go offline and your project would be broken then as it requires a non-existing gem any longer.

This is no legal advice, just from a programmers perspective. Consider that users of your software ask for sources from you as your software makes use of the library and it can be actually seen as distribution because you wrote require "somegem" in there. The legal definition of distribution might not match a programmers day-to-day expectation of burning files onto a cd-rom. So it's wise to have a more broad conception here to stay pro-active in case things don't turn out as expected.

OwnerDisplayName: corsen


答:
SOLID is a very good starting point. These are the 5 basic principles of object oriented design, which state what follows:

Single responsibility principle: your objects (classes) should have single responsibility. In other words, there should be only one reason to change given entity/class.

Open/Closed principle: classes should be open for extension, closed for modification. Classes itselves shouldn't change much, yet they should provide extension points so their behavior can be altered/expanded by future implementators.

Liskov substitution principle: each object should be replacable by its more specific subtype without altering correctness of program. As in, if something works with Mammal type, it should work just as good with Tiger and Panda types.

Interface segregation principle: by Wiki "many client specific interfaces are better than one general purpose interface". This goes in pair with SRP and decoupled design - you should prefer multiple task-specific entities instead of single general-purpose one.

Dependency inversion principle: you should design by contract, not by concrete implementation. Which often narrows down to having contracts (interfaces) passed arround as dependencies instead of their implementations (classes).

Reading up on those topics should probably spawn new questions and lead you to further research. Which should probably include (among others) following important concepts:

composition over inheritance

dependency injection, IoC containers

design for testability, TDD

Title: Recommended reading for (Object Oriented) application design architecture?

Body:
Possible Duplicate:

  Best books on the theory and practice of software architecture?

In life it doesnt matter if you do one thing for 15 years. You will end up waking one day and asking stuff that are equal to  "how do i walk?" :)

My specific question is that as a new entrant to C# and OOP i am stepping into many little "details" that need to be addressed.

Written a lot of code in VB.NET / cobol / simple php e.t.c surely does not help much into the OOP world...

So , even after reading entry level books for C# and watching some videos i recently found out about the "factory model design" for applications.

I would appreciate if any of you guys recomment some reading on application design architecture for further reading...


问:
How often are comments used in XML documents?
I'm currently developing a web-based XML managing program for a client (though I may 'market' it for future clients). Currently, it reads an XML document, converts it into manageable Javascript objects, and ultimately spits out indented, easy to read XML code. Edit: The program would be used by clients that don't feel like learning XML to add items or tags, but I (or another XML developer) may use the raw data for quick changes without using an editor.

I feel like fundamentally, its ready for release, but I'm wondering if I should go the extra mile and allow support for remembering (and perhaps making) comments before generating the resulting XML.

Considering that these XML files will probably never be read without a program interpreting it, should I really bother adding support for comments? I'll probably be the only one looking at raw files, and I usually don't use comments for XML anyway.

So, are comments common/important in most XML documents?

答:
Comments are to make code more human readable. They should be used as such.

If your XML is going read by humans (ie config files) then comments are good. If they aren't then they are just bloat and should be left out.


问:
How to generate "language-safe" UUIDs?
I always wanted to use randomly generated strings for my resources' IDs, so I could have shorter URLs like this: /user/4jz0k1

But I never did, because I was worried about the random string generation creating actual words, eg: /user/f*cker. This brings two problems: it might be confusing or even offensive for users, and it could mess with the SEO too.

Then I thought all I had to do was to set up a fixed pattern like adding a number every 2 letters. I was very happy with my 'generate_safe_uuid' method, but then I realized it was only better for SEO, and worse for users, because it increased the ratio of actual words being generated, eg: /user/g4yd1ck5

Now I'm thinking I could create a method 'replace_numbers_with_letters', and check that it haven't formed any words against a dictionary or something.

Any other ideas?

ps. As I write this, I also realized that checking for words in more than one language (eg: english and french, spanish, etc) would be a mess, and I'm starting to love numbers-only IDs again.

UPDATE

Some links everyone should read:

http://thedailywtf.com/Articles/The-Automated-Curse-Generator.aspx

Link

答:
You can never prevent an automated system from generating some string that's offensive to a user. For example, in China some numbers are considered unlucky.

All you can really do is tell the user that their ID is random and the contents are irrelevant and if they get /user/fucker then they should just ignore it. These things happen and it's just not technically feasible to avoid it- just like you can never filter profanity.

ContentLicense: CC BY-SA 4.0

Title: How to generate "language-safe" UUIDs?


答:
A couple of tips that will lower the chances of inadvertently creating meaningful words:

Add some non-alpha, non-numerical characters to the mix, such as "-", "!" or "_".

Compose your UUIDs by accumulating sequences of characters (rather than single characters) that are unlikely to occur in real words, such as "zx" or "aa".

This is some C# sample code (using .NET 4):

```<code>private string MakeRandomString()
{
    var bits = new List<string>()
    {
            "a",
            "b",
            "c",
            "d",
            "e",
            //keep going with letters.
            "0",
            "1",
            "2",
            "3",
            //keep going with numbers.
            "-",
            "!",
            "_",
            //add some more non-alpha, non-numeric characters.
            "zx",
            "aa",
            "kq",
            "jr",
            "yq",
            //add some more odd combinations to the mix.
    };

    StringBuilder sb = new StringBuilder();
    Random r = new Random();
    for (int i = 0; i < 8; i++)
    {
        sb.Append(bits[r.Next(bits.Count)]);
    }

    return sb.ToString();
}
</code>```

This doesn't guarantee that you won't offend anyone, but I agree with @DeadMG that you cannot aim so high.

Title: How to generate "language-safe" UUIDs?

Body:
I always wanted to use randomly generated strings for my resources' IDs, so I could have shorter URLs like this: /user/4jz0k1

But I never did, because I was worried about the random string generation creating actual words, eg: /user/f*cker. This brings two problems: it might be confusing or even offensive for users, and it could mess with the SEO too.

Then I thought all I had to do was to set up a fixed pattern like adding a number every 2 letters. I was very happy with my 'generate_safe_uuid' method, but then I realized it was only better for SEO, and worse for users, because it increased the ratio of actual words being generated, eg: /user/g4yd1ck5

Now I'm thinking I could create a method 'replace_numbers_with_letters', and check that it haven't formed any words against a dictionary or something.

Any other ideas?

ps. As I write this, I also realized that checking for words in more than one language (eg: english and french, spanish, etc) would be a mess, and I'm starting to love numbers-only IDs again.

UPDATE

Some links everyone should read:

http://thedailywtf.com/Articles/The-Automated-Curse-Generator.aspx

Link

Body:
A couple of tips that will lower the chances of inadvertently creating meaningful words:

Add some non-alpha, non-numerical characters to the mix, such as "-", "!" or "_".

Compose your UUIDs by accumulating sequences of characters (rather than single characters) that are unlikely to occur in real words, such as "zx" or "aa".

This is some C# sample code (using .NET 4):

private string MakeRandomString()
{
    var bits = new List<string>()
    {
            "a",
            "b",
            "c",
            "d",
            "e",
            //keep going with letters.
            "0",
            "1",
            "2",
            "3",
            //keep going with numbers.
            "-",
            "!",
            "_",
            //add some more non-alpha, non-numeric characters.
            "zx",
            "aa",
            "kq",
            "jr",
            "yq",
            //add some more odd combinations to the mix.
    };

    StringBuilder sb = new StringBuilder();
    Random r = new Random();
    for (int i = 0; i < 8; i++)
    {
        sb.Append(bits[r.Next(bits.Count)]);
    }

    return sb.ToString();
}

This doesn't guarantee that you won't offend anyone, but I agree with @DeadMG that you cannot aim so high.


问:
Biggest mistake you've ever made
Similar to the question I read on Server Fault, what is the biggest mistake you've ever made in an IT related position. Some examples from friends:

I needed to do some work on a production site so I decided to copy over the live database to the beta site. Pretty standard, but when I went to the beta site it was still pulling out-of-date info. OOPS! I had copied the beta database over to the live site! Thank god for backups.

And for me, I created a form for an event that was to be held during a specific time range. Participants would fill out the form for a chance to win, and we would send the event organizers a CSV from the database. I went into the database, and found ONLY 1 ENTRY, MINE. Upon investigating, it appears as though I forgot an auto increment key, and because of the server setup there was no way to recover the lost data.

I am aware this question is similar to ones on Stack Overflow but the ones I found seemed to receive generic answers instead of actual stories :)

What is the biggest coding error/mistake ever…

答:
Typo's

Spent three solid days on this chunk:

```<code>if($func == "remove")
{
    $p->comments[$index]->removed = true;
    $p->save();
}
else if($func == "approve");
{
    $p->comments[$index]->approved = true;
    $p->comments[$index]->removed = false;
    $p->save();
}
</code>```

See the error? It's the semicolon at the end of the else if. I couldn't figure out why my removed comments weren't removing. Dug into the database, the AJAX request I was using, POST variables, had error_log's and alerts everywhere. Ended up re-writing the method and it worked. Then I did a diff with the original version and noticed the semicolon.

Typo's are the hardest to track down on a language that isn't compiled or pre-checked by something. Even errors like this would be difficult on a compiled language. Change a == to = and suddenly you have assignment inside an if.

Title: Biggest mistake you've ever made

Body:
Typo's

Spent three solid days on this chunk:

if($func == "remove")
{
    $p->comments[$index]->removed = true;
    $p->save();
}
else if($func == "approve");
{
    $p->comments[$index]->approved = true;
    $p->comments[$index]->removed = false;
    $p->save();
}

See the error? It's the semicolon at the end of the else if. I couldn't figure out why my removed comments weren't removing. Dug into the database, the AJAX request I was using, POST variables, had error_log's and alerts everywhere. Ended up re-writing the method and it worked. Then I did a diff with the original version and noticed the semicolon.

Typo's are the hardest to track down on a language that isn't compiled or pre-checked by something. Even errors like this would be difficult on a compiled language. Change a == to = and suddenly you have assignment inside an if.


答:
Just create a naughty word list, a letter substitution list, and then if any ID generated is a naughty word, redo it.

For instance (pseudo code)

```<code>naughty_words = ["ass", "shit", "boobs"]
substitutions = {
    "4" : "a"
    "1" : "i"
    "3" : "e"
    "7" : "t"
    "5" : "s"
    "0" : "o"
    // etc.
}

function reducestring (str) {
    newstr = ""
    for (character in str) {
        if (substitituions[character]) newstr += substitutions[character]
        else newstr += character
    }
    return tolower(newstr)
}

do {
    new_id_numeric = random_number()
    short_id = compress_to_alphanumeric(new_id_numeric) // 0-9, a-z, A-Z
    // that function should create a base 62 number
} while (!contains(naughty_words, reducestring(short_id))
</code>```

(You can refer to other short url recommendations like this one for info on base 62 hashing/conversion)

Now you no longer get IDs like a55, sh1t, or "b00bs".  Your letter substitution list would only need to contain characters in your naughty words, obviously.

Since no one is going to read "455" as "ass" then you might also want to return str in reducestring if it doesn't contain any letters.

Examples

The graphic-design site Dribbble has its own short string ids for posts.  These use 0-9, a-z and A-Z like http://drbl.in/dCWi.

I did some experimenting and there are short ids for at least a few naughty words.  I guess we'll see when they get to f, but they aren't there yet.

http://drbl.in/dick - http://dribbble.com/shots/443570-New-Logo-Ideas-II

http://drbl.in/butt - http://dribbble.com/shots/195695-Office

Granted -- giving a user their own personally-identifying url (/user/whatever) instead of just a post is much worse with naughty words.

Title: How to generate "language-safe" UUIDs?

Body:
Just create a naughty word list, a letter substitution list, and then if any ID generated is a naughty word, redo it.

For instance (pseudo code)

naughty_words = ["ass", "shit", "boobs"]
substitutions = {
    "4" : "a"
    "1" : "i"
    "3" : "e"
    "7" : "t"
    "5" : "s"
    "0" : "o"
    // etc.
}

function reducestring (str) {
    newstr = ""
    for (character in str) {
        if (substitituions[character]) newstr += substitutions[character]
        else newstr += character
    }
    return tolower(newstr)
}

do {
    new_id_numeric = random_number()
    short_id = compress_to_alphanumeric(new_id_numeric) // 0-9, a-z, A-Z
    // that function should create a base 62 number
} while (!contains(naughty_words, reducestring(short_id))

(You can refer to other short url recommendations like this one for info on base 62 hashing/conversion)

Now you no longer get IDs like a55, sh1t, or "b00bs".  Your letter substitution list would only need to contain characters in your naughty words, obviously.

Since no one is going to read "455" as "ass" then you might also want to return str in reducestring if it doesn't contain any letters.

Examples

The graphic-design site Dribbble has its own short string ids for posts.  These use 0-9, a-z and A-Z like http://drbl.in/dCWi.

I did some experimenting and there are short ids for at least a few naughty words.  I guess we'll see when they get to f, but they aren't there yet.

http://drbl.in/dick - http://dribbble.com/shots/443570-New-Logo-Ideas-II

http://drbl.in/butt - http://dribbble.com/shots/195695-Office

Granted -- giving a user their own personally-identifying url (/user/whatever) instead of just a post is much worse with naughty words.


问:
Differences between symfony 2 and 1?
I'm starting symfony and interested in learning where symfony is coming from. In terms of it's architectural challenges.

What are the architectural or philosophical differences between symfony 2 and 1?

What changes make it so different from the other point version?

答:
The relevant cookbook entry explains the main differences.

Not an expert, but here are some points:

Symfony2 takes advantage of the latest features of PHP(namespaces etc).

It's built from stand-alone components. The decoupled nature of it makes it easier to integrate it with other systems.

The bundle system. In Sf1 there were apps, like backend app, frontend app, and plugins. In Sf2, its advised to build application with bundles, with each bundle doing a different job. This allows to you separate your application in different bundles, so it's easier to reuse them in other projects.

Title: Differences between symfony 2 and 1?


问:
Java - multirow array
Here is my situation: a company has x number of employees and x number of machines.
When someone is sick, the program have to give the best possible solution of people on the machines. But the employees can't work on every machine. I need a code for making little groups of possible solutions.

this is a static example
private int[][] arrayCompetenties={{0,0,1,0,1},{1,0,1,0,1},{1,1,0,0,1},{1,1,1,1,1},{0,0,0,0,1}};
=> row is for the people and columns are for machines

```<code>    m1  m2  m3  m4  m5  m6  m7
p1  1               1
p2      1   1   1   1
p3          1       1       1
p4      1       1       1
p5  1       1       1       1
p6              1   1   1   1
p7  1       1   1   1   1   1
</code>```

my question => with what code do i connect all the people to machine in groups (all the posibilities)

like:

p1 -> m1 , p2->m2 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m3 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m4 , p3 -> m5 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m5 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m2 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

....

i need a loop buth how? =D

thanks!

答:
I think you're trying to to generate all permutations of machines and users. Take a look at that link, especially on the algorithms used to generate permutations.

Keep in mind that the number of permutations for n machines/users is n! (n factorial, or n * (n-1) * (n-2) * ... * 2 * 1), which grows extremely quickly -- for 10 users, 3.6 million possibilities, and for a company of 50 people, you're looking at 3.0 * 10^64 different combinations, which wouldn't fit on all the world's computers.

Title: Java - multirow array


答:
This can be handled by specifying the snippet in question as an external system entity.

```<code><xml version="1.0">

<!DOCTYPE root [
<!ENTITY about SYSTEM "path/to/about.xml">
]>

<root>
&about;
</root>
</code>```

The W3C recommendation use the term "Parameter-entity" for this.  See http://www.w3.org/TR/2004/REC-xml-20040204/#dt-PERef for the formal definition.

Title: XML: Multiple roots + text content outside the root. Does anyone do it?

Body:
I have another one of those "is it done in XML" questions (my last one about xml comments hasn't been answered if anyone has a good explanation)

I was just wondering if anyone, anywhere would:

Use multiple root elements in an XML document

Put text content outside of a root element

W3C discourages these practices, Javascript's DOMParser doesn't even allow these cases, and I can't think of one sane reason to do either of these things. However, I know how bizarre some implementations of XML have been, so I wouldn't be surprised.

Does anyone have any real world examples where this would be done? I will also accept an answer that specifies if other mainstream parsers allow doing either of these.

Body:
This can be handled by specifying the snippet in question as an external system entity.

<xml version="1.0">

<!DOCTYPE root [
<!ENTITY about SYSTEM "path/to/about.xml">
]>

<root>
&about;
</root>

The W3C recommendation use the term "Parameter-entity" for this.  See http://www.w3.org/TR/2004/REC-xml-20040204/#dt-PERef for the formal definition.


问:
Standard way of allowing general XML data
I'm writing a data gathering and reporting application that takes XML files as input, which will then be read, processed, and stored in a strongly-typed database. For example, an XML file for a "Job" might look like this:

```<code><Data type="Job">
    <ID>12345</ID>
    <JobName>MyJob</JobName>
    <StartDate>04/07/2012 10:45:00 AM</StartDate>
    <Files>
        <File name="a.jpeg" path="images\" />
        <File name="b.mp3" path="music\mp3\" />
    </Files>
</Data>
</code>```

I'd like to use a schema to have a standard format for these input files (depending on what type of data is being used, for example "Job", "User", "View"), but I'd also like to not fail validation if there is extra data provided.

For example, perhaps a Job has additional properties such as "IsAutomated", "Requester", "EndDate", and so on. I don't particularly care about these extra properties. If they are included in the XML, I'll simply ignore them when I'm processing the XML file, and I'd like validation to do the same, without having to include in the schema every single possible property that a customer might provide me with.

Is there a standard way of providing such a schema, or of allowing such a general XML file that can still be validated without resorting to something as naïve (and potentially difficult to deal with) as the below?

```<code><Data type="Job">
    <Data name="ID">12345</Data>
    . . .
    <Data name="Files">
        <Data name="File">
            <Data name="Filename">a.jpeg</Data>
            <Data name="path">images</Data>
        . . .
    </Data>
</Data>
</code>```

答:
I'm actually working on something similar, and I've settled with using a JSON file on the server that describes what type of elements/attributes are allowed.

When a user uploads a XML file, it can be compared to the data file on the server through a script, and elements or attributes with improper syntax can be rejected.

As far as a standard way of doing this, I'm not aware of any, though this method has been working quite well for me so far.

Here's what my test JSON object looks like:

EDIT: It's actually an object literal, but whatever ;)

```<code>XMLTemplate = {
    xml         : '<?xml version="1.0" encoding="UTF-8" ?>',
    doctype     : '<!DOCTYPE xml PUBLIC>',
    children    : [{

                   name     : "ROOT",
                   description  : "All xml documents have a root tag",

                   children : [{
                               name         : "GROUP",
                               description  : "Groups contain products, as well as some fields",
                               attributes   : [{
                                               name         : "TYPE",
                                               description  : "What type of product"
                                               },{
                                               name         : "DESCRIPTION",
                                               description  : "Group Description"
                                               }],

                               children : [{

                                           name         : "TITLE",
                                           description  : "Title of the group"

                                           },{

                                           name         : "DESCRIPTION",
                                           description  : "Group description",

                                           attributes   : [{
                                                           name         : "SOMETHINGELSE",
                                                           description  : "some other attribute I don't know"
                                                           },{
                                                           name         : "WIDTH",
                                                           description  : ""
                                                           }]

                                           },{

                                           name         : "PRODUCT",
                                           description  : "Products contain some stuffs",
                                           attributes   : [{
                                                           name : "TYPE",
                                                           description  : "type of product"
                                                           },{
                                                           name         : "SOMETHINGELSE",
                                                           description  : "some other attribute I don't know"
                                                           }],

                                           }]

                               }]
                   }]
}
</code>```

Body:
I'm actually working on something similar, and I've settled with using a JSON file on the server that describes what type of elements/attributes are allowed.

When a user uploads a XML file, it can be compared to the data file on the server through a script, and elements or attributes with improper syntax can be rejected.

As far as a standard way of doing this, I'm not aware of any, though this method has been working quite well for me so far.

Here's what my test JSON object looks like:

EDIT: It's actually an object literal, but whatever ;)

XMLTemplate = {
    xml         : '<?xml version="1.0" encoding="UTF-8" ?>',
    doctype     : '<!DOCTYPE xml PUBLIC>',
    children    : [{

                   name     : "ROOT",
                   description  : "All xml documents have a root tag",

                   children : [{
                               name         : "GROUP",
                               description  : "Groups contain products, as well as some fields",
                               attributes   : [{
                                               name         : "TYPE",
                                               description  : "What type of product"
                                               },{
                                               name         : "DESCRIPTION",
                                               description  : "Group Description"
                                               }],

                               children : [{

                                           name         : "TITLE",
                                           description  : "Title of the group"

                                           },{

                                           name         : "DESCRIPTION",
                                           description  : "Group description",

                                           attributes   : [{
                                                           name         : "SOMETHINGELSE",
                                                           description  : "some other attribute I don't know"
                                                           },{
                                                           name         : "WIDTH",
                                                           description  : ""
                                                           }]

                                           },{

                                           name         : "PRODUCT",
                                           description  : "Products contain some stuffs",
                                           attributes   : [{
                                                           name : "TYPE",
                                                           description  : "type of product"
                                                           },{
                                                           name         : "SOMETHINGELSE",
                                                           description  : "some other attribute I don't know"
                                                           }],

                                           }]

                               }]
                   }]
}


答:
The easiest way to solve this is with recursion.  The following is very pseudocode because the data structures aren't trivial, but you get the idea:</p>

```<code>printMachineAssignments(person, assignedMachines)
    for every machine in person's competencies that's not in assignedMachines
        assign person to machine
        add machine to assignedMachines
        if no more people
            print assignments to the screen
        else
            printMachineAssignments(person + 1, assignedMachines)
</code>```

Title: Java - multirow array

Body:
Here is my situation: a company has x number of employees and x number of machines.
When someone is sick, the program have to give the best possible solution of people on the machines. But the employees can't work on every machine. I need a code for making little groups of possible solutions.

this is a static example
private int[][] arrayCompetenties={{0,0,1,0,1},{1,0,1,0,1},{1,1,0,0,1},{1,1,1,1,1},{0,0,0,0,1}};
=> row is for the people and columns are for machines

```<code>    m1  m2  m3  m4  m5  m6  m7
p1  1               1
p2      1   1   1   1
p3          1       1       1
p4      1       1       1
p5  1       1       1       1
p6              1   1   1   1
p7  1       1   1   1   1   1
</code>```

my question => with what code do i connect all the people to machine in groups (all the posibilities)

like:

p1 -> m1 , p2->m2 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m3 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m4 , p3 -> m5 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m5 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

p1 -> m1 , p2->m2 , p3 -> m3 , p4->m4 , p5 -> m5 , p6->m6

....

i need a loop buth how? =D

thanks!

Body:
The easiest way to solve this is with recursion.  The following is very pseudocode because the data structures aren't trivial, but you get the idea:

printMachineAssignments(person, assignedMachines)
    for every machine in person's competencies that's not in assignedMachines
        assign person to machine
        add machine to assignedMachines
        if no more people
            print assignments to the screen
        else
            printMachineAssignments(person + 1, assignedMachines)


答:
XSD is the way to go if your file format is XML -- this is exactly the sort of task XSD is meant for and it really does shine in this space.

To handle your optional elements you can do two things. The first is to define them as optional attributes using minOccours="0". If you've got something more complex going on you could also use the processContents="lax" directive.

Title: Standard way of allowing general XML data

Body:
I'm writing a data gathering and reporting application that takes XML files as input, which will then be read, processed, and stored in a strongly-typed database. For example, an XML file for a "Job" might look like this:

```<code><Data type="Job">
    <ID>12345</ID>
    <JobName>MyJob</JobName>
    <StartDate>04/07/2012 10:45:00 AM</StartDate>
    <Files>
        <File name="a.jpeg" path="images\" />
        <File name="b.mp3" path="music\mp3\" />
    </Files>
</Data>
</code>```

I'd like to use a schema to have a standard format for these input files (depending on what type of data is being used, for example "Job", "User", "View"), but I'd also like to not fail validation if there is extra data provided.

For example, perhaps a Job has additional properties such as "IsAutomated", "Requester", "EndDate", and so on. I don't particularly care about these extra properties. If they are included in the XML, I'll simply ignore them when I'm processing the XML file, and I'd like validation to do the same, without having to include in the schema every single possible property that a customer might provide me with.

Is there a standard way of providing such a schema, or of allowing such a general XML file that can still be validated without resorting to something as naïve (and potentially difficult to deal with) as the below?

```<code><Data type="Job">
    <Data name="ID">12345</Data>
    . . .
    <Data name="Files">
        <Data name="File">
            <Data name="Filename">a.jpeg</Data>
            <Data name="path">images</Data>
        . . .
    </Data>
</Data>
</code>```


答: I once used a cross join without a filter.  Worked just fine on the test database with a fraction of the data.  When it was deployed, it ended up with ~60M rows in an average query. </p>

Title: Biggest mistake you've ever made

Body:
Similar to the question I read on Server Fault, what is the biggest mistake you've ever made in an IT related position. Some examples from friends:

I needed to do some work on a production site so I decided to copy over the live database to the beta site. Pretty standard, but when I went to the beta site it was still pulling out-of-date info. OOPS! I had copied the beta database over to the live site! Thank god for backups.

And for me, I created a form for an event that was to be held during a specific time range. Participants would fill out the form for a chance to win, and we would send the event organizers a CSV from the database. I went into the database, and found ONLY 1 ENTRY, MINE. Upon investigating, it appears as though I forgot an auto increment key, and because of the server setup there was no way to recover the lost data.

I am aware this question is similar to ones on Stack Overflow but the ones I found seemed to receive generic answers instead of actual stories :)

What is the biggest coding error/mistake ever…


问:
Rpc transferring data or Replication
I have services on 10 machines that stores data in database on these machines.
And I have main server that needs to pull that data from these ten machines.
What is better for this. Implement some rpc or use replication? </p>

答:
It depends on how much data you need to get and how often.

If your data has to be updated often and there aren't peaks, then Remote Procedure Call or Web Services or File Transfer are a good solution.

You could also try to post your question to: https://dba.stackexchange.com/

Title: Rpc transferring data or Replication


问:
What are the disadvantages of naming things alphabetically?
Let me give you an example of how I name my classes alphabetically:

Car

CarHonda (subclass of Car)

CarHondaAccord (subclass of CarHonda)

There are two reasons why I put the type of the class earlier in its name:

When browsing your files alphabetically in a file explorer, related items appear grouped together and parent classes appear above child classes.

I can progressively refine auto-complete in my IDE. First I type the major type, then the secondary type, and so on without having to memorize what exactly I named the last part of the thing.

My question is why do I hardly see any other programmers do this? They usually name things in reverse or some random order. Take the iOS SDK for example:

UIViewController

UITableViewController

What are the disadvantages of my naming convention and the advantages of their convention?

答:
I think this is because in English adjectives come before nouns and you would say I bought a Honda car rather than I bought a car Honda.

If you have long lists of classes, you can move some classes into a new package.