问:
Best way to maintain data between local and remote sql databases
So I have, what would seem like a common question that I can't seem to find an answer to. I'm trying to find what is the "best practice" for how to architect a database that maintains data locally, then syncs that data to a remote database that is shared between many clients. To make things more clear, this remote database would have many clients that use it.

For example, if I had a desktop application that stored to-do lists (in SQL) that had individual items. Then I want to be able to send that data to a web-service that had a "master" copy of all the different clients information. I'm not worried about syncing problems as much as I am just trying to think through actual architecture of the client's tables and the web-services tables

Here's an example of how I was thinking about it:

Client Database

```<code>list
--list_client_id (primary key, auto-increment)
--list_name

list_item
--list_item_client_id (primary key, auto-increment)
--list_id
--list_item_text
</code>```

Web Based Master Database (Shared between many clients)

```<code>list
--list_master_id
--list_client_id (primary key, auto-increment)
--list_name
--user_id

list_item
--list_item_master_id (primary key, auto-increment)
--list_item_remote_id
--list_id
--list_item_text
--user_id
</code>```

The idea would be that the client can create todo lists with items, and sync this with the web service at any given time (i.e. if they lose data connectivity, and aren't able to send the information until later, nothing will get out of order). The web service would record the records with the clients id's as just extra fields.
That way, the client can say "update list number 4 with a new name" and the server takes this to mean "update user 12's list number 4 with a new name".

答: I understand you want a local store e.g. local copy of todo list then upload the data, syncing back to the master database. Writing the services isn't the hard part, but managing the syncing between databases. I've recently being looking into nServiceBus http://nservicebus.com/ to improve the management of data syncing between systems. It's area I'm interesting in but have yet to have found the best aproach or magic bullet. I'd recommend taking a look into nServiceBus. </p>


问:
JavaScript for a non-programmer
2 years ago I starded learning AS3 in order to get hired at a web design company. A few months later, I ditched it, because I discovered that I'm better at design; so now I'm a web designer.

Recently, I decided that knowing JavaScript would be nice and helpful, so i started with Essential JavaScript Training from Lynda.com. Untill today, I was under the impression that my knowledge of programming was somewhat basic. What happened today...?
I learned (through trial and error) that variables are only valid in the functions that they're defined in. This turned my world upside down. I was like: "that makes sense now..." thinkin of the all the headaches that the lack of this specific piece of knowledge gave me.
How could I have missed such a fundamental thing while learning AS3 (and now JS)? I didn't. And I remember reading a at least three books on AS3, but none of them taught me about programming.

So what I want to ask you, is if you could recommend me a good JavaScript book from which i can learn programming, too, besides syntax.

Thanks! And sorry for my bad english :)

答:
I'd recommend a few links all located at:
http://javascript.crockford.com/

The problem with JavaScript is there is a lot of really bad advice out there, the link above may be a bit of a rant from the author but he knows what he is doing.

JavaScript can be a horrible thing to write and maintain or something very easy and fluid. The choice is in how you use it.

http://javascript.crockford.com/code.html for conventions.

ContentLicense: CC BY-SA 2.5

Title: JavaScript for a non-programmer


问:
Is rethrowing an exception leaking an abstraction?
I have an interface method that states in documentation it will throw a specific type of exception.  An implementation of that method uses something that throws an exception.  The internal exception is caught and the exception declared by the interface contract is thrown.  Here's a little code example to better explain.  It is written in PHP but is pretty simple to follow.

```<code>// in the interface

/**
 * @return This method returns a doohickey to use when you need to foo
 * @throws DoohickeyDisasterException
 */
public function getThatDoohickey();

// in the implementation

public function getThatDoohickey() {

    try {
        $SomethingInTheClass->doSomethingThatThrowsAnException();
    } catch (Exception $Exc) {
        throw new DoohickeyDisasterException('Message about doohickey failure');
    }

    // other code may return the doohickey

}
</code>```

I'm using this method in an attempt to prevent the abstraction from leaking.

My questions are: Would passing the thrown internal exception as the previous exception be leaking the abstraction?  If not, would it be suitable to simply reuse the previous exception's message?  If it would be leaking the abstraction could you provide some guidance on why you think it does?

Just to clarify, my question would involve changing to the following line of code

```<code>throw new DoohickeyDisasterException($Exc->getMessage(), null, $Exc);
</code>```

答:
My questions are: Would passing the thrown internal exception as the previous exception be leaking the abstraction? If not, would it be suitable to simply reuse the previous exception's message?

The answer is: "it depends".

Specifically, it depends on the exception, and what it means.  In essence, rethrowing it means you are adding that to your interface.  Would you do that if you wrote the code you are calling yourself, or is this just to avoid rebranding the exception?

If your exception includes a trace down to the root cause, in the called code, that might leak data outside the abstraction - but, generally, I think that is acceptable because the exception is either handled by the caller (and no one cares where it came from) or shown to the user (and you want to know the root cause, for debugging.)

Frequently, though, just allowing the exception through is a very reasonable choice of implementation, and not a problem of abstraction.  Just ask "would I throw this if the code I am calling didn't?"

ContentLicense: CC BY-SA 3.0


答:
The rule I try to go by is: wrap it if you caused it. Similarly, if a bug were to be created because of a runtime exception, it should be some sort of DoHickeyException or MyApplicationException.

What that implies is that if the cause of the error is something external to your code, and you're not expecting it to fail then fail gracefully and rethrow it. Likewise, if it's a problem with your code, then wrap it in a (potentially) custom exception.

For instance, if a file is expected to be on disk, or a service is expected to be available, then handle it gracefully and re-throw the error so that the consumer of your code can figure out why that resource is unavailable. If you created too much data for some type, then it's your error to wrap and throw.

Title: Is rethrowing an exception leaking an abstraction?

Body:
I have an interface method that states in documentation it will throw a specific type of exception.  An implementation of that method uses something that throws an exception.  The internal exception is caught and the exception declared by the interface contract is thrown.  Here's a little code example to better explain.  It is written in PHP but is pretty simple to follow.

```<code>// in the interface

/**
 * @return This method returns a doohickey to use when you need to foo
 * @throws DoohickeyDisasterException
 */
public function getThatDoohickey();

// in the implementation

public function getThatDoohickey() {

    try {
        $SomethingInTheClass->doSomethingThatThrowsAnException();
    } catch (Exception $Exc) {
        throw new DoohickeyDisasterException('Message about doohickey failure');
    }

    // other code may return the doohickey

}
</code>```

I'm using this method in an attempt to prevent the abstraction from leaking.

My questions are: Would passing the thrown internal exception as the previous exception be leaking the abstraction?  If not, would it be suitable to simply reuse the previous exception's message?  If it would be leaking the abstraction could you provide some guidance on why you think it does?

Just to clarify, my question would involve changing to the following line of code

```<code>throw new DoohickeyDisasterException($Exc->getMessage(), null, $Exc);
</code>```


问:
What is the best way to divide work among developers
My team and I are rebuilding a site we developed around ten years ago, and we want to do it in Agile.

So after I spent a lot of time reading (probably not enough) I am having trouble with the question how to divide work between developers.

I'll be more specific and say that the site is divided to separate modules that doesn't have much integration between one another.

What is the best / Most accepted way to divide the work between the developers?

Giving each person a different module to work on.

Assign all developers to the same module, and split the work by different parts of the module (UnitTesting, DAL and Mapping, Logics, UI)

Assign all developers to the same module, and split the work by different logics (For example each developer is in-charge of a specific logic(probably a method in the BL) and It's UnitTesting, DAL and Mapping and UI...

Or maybe something entirely different?

答:
Here is what I would do:

If all the modules are small, then you can give each a module to work on. Otherwise, do this:

Define each module size, complexity, skills required to do it.

Define each team member skills.

Define which people work together well and which ones don't work with others well.

Assign large modules to teams of people that work together well based on module skill requirements and team skills.

Assign remaining modules to people who can't work well with other people based on module skill requirements and team skills.

The above will not work if the people who don't like to work with others are the most proficient ones and this is a common case, so make an exception to 4 and 5 accordingly

OwnerDisplayName: Amir

OwnerDisplayName: Emmad Kareem


答: Have a meeting with the team, show them the to-do list, and ask who wants to do what.</p>

Title: What is the best way to divide work among developers

Body:
My team and I are rebuilding a site we developed around ten years ago, and we want to do it in Agile.

So after I spent a lot of time reading (probably not enough) I am having trouble with the question how to divide work between developers.

I'll be more specific and say that the site is divided to separate modules that doesn't have much integration between one another.

What is the best / Most accepted way to divide the work between the developers?

Giving each person a different module to work on.

Assign all developers to the same module, and split the work by different parts of the module (UnitTesting, DAL and Mapping, Logics, UI)

Assign all developers to the same module, and split the work by different logics (For example each developer is in-charge of a specific logic(probably a method in the BL) and It's UnitTesting, DAL and Mapping and UI...

Or maybe something entirely different?


答:
Although I do agree with David's answer, I felt it could profit from some elaborating:

Agile means, you do not make these decisions and push them onto the team. There is no project manager/leader like that. Only the team.

The ones who know best, how to divide work are the team members themselves.

Discuss your backlog, and find out what you want to realize in the next iteration/sprint.

Use planning poker or similar methods to get an idea of how much work you are going to divide anyways, and only then start dividing up actual work packages together.

Basically, the bottom line is: No one here on SE can answer that question for you, nor is there much of a point to it, because it's much better if you come up with an answer as a team.


答:
My team has been trying to go "agile" for few releases now, but being part of a large corporation hasn't exactly made it easy. I won't pretend like I have the answer, but I can share some of my observations.

Dividing developers per module:

You need to be careful because if people work too much in isolation, your team doesn't benefit from cross-sharing of skills and knowledge

Planning meetings and daily stand ups can become incredibly dull to everyone if people focus too much on their own modules and don't see bigger picture.  Once people get bored, they start checking out and you lose much of the benefit agile brings to the table

You might end up with some components written really well, and other components, well... not so much. If people work in isolation, your senior guys won't be able to train the junior ones.

Everyone works on the same module at the same time

We tried that for one release, when management decided they will impose agile on the whole team and it will be completely their way.  It as an absolute train wreck.  We had a team of 9 developers deliver in a year what typically would've been done by 1 developer. (I might be exaggerating here but not by much).

No one felt like there was any breathing room. Those that didn't care about software, felt right at home because being part of a larger pack, they just get diluted in the group. Those of us who had passion for software, felt absolutely stifled as there was no freedom to move or go outside the bounds what 9 people have agreed on.

All meetings went forever to a point of me wanting to shoot myself. Too many people with an opinion in the same room forced to work on the same freakin' DLL. The horror.

In the last release, we've decided to try something different

First and foremost, break development group into smaller teams of 3-4 developers. Each team worked in relative isolation from each other but within the team people worked much more cohesively

With this approach, stand ups are fast and planning meetings take 1-2 hours compared to solid 4 hours.

Everyone feels engaged because each team only discusses what the developers on that team care about.

Tech lead from each team talks to other tech leads periodically to make sure overall project is on track.

Instead of making people "owner" of a specific module, we assigned areas of expertise to people, so when we first started the project it felt like people have their own module, but after several months, developers would start looking at each others code as areas started overlapping.

Code reviews are essential. This was the second release where we had strict code review policy and everyone on the team loves them.  Expert of a specific area is always on a code review when someone else modifies that code.

With code reviews we have a ton of knowledge sharing and you can visible see the overall improvement of our teams' code quality. Also because code gets reviewed so often, when people go into someone else's area of expertise, chances are they've already seen the code at least few times already.

Larger portion of each team is sucked into design review meetings, so even if they've never seen the code, everyone is familiar with general flow of all modules that their team is responsible for.

We've done this for about 10 months and it kind of feels like we started with isolated module approach and morphed into everyone works on everything. But at the same time, no one feels like they are cramped or limited. And to make sure the guys still have sense of some authority, we left them as area experts, even though that's mostly a formality now.

We've been doing that last thing, and although there's a ton of room for improvements, overall our entire team has been very happy and that says a lot, when we are part of giant corporation.

One important thing that we got wrong the first 3 times we "went agile", is each one of those times people were told how to work and they were told what to work on. That's number one way to have your team completely lose interest in the project and then you are in real trouble.

Instead, try the opposite. Tell the team, they can do whatever they want and as a manager/leader (if you are one, if not make your manager repeat these words), your job is to make sure they are as productive and happy as possible.  Process is not a bad thing, but process should be there to help your team when it realizes it needs one, not the other way around.

If some of your team members prefer to work in isolation, let them (to a degree). If they prefer to work in pairs, let them do that. Make sure to let your people pick their own work as much as you can.

Lastly, and this is very important and is always overlooked.  YOU WILL NOT GET THIS RIGHT (unless you are superman, or at least batman).  Having regular retrospective meetings is extremely important. When we rolled out retrospectives, they were done by the book and it felt like yet another process you had to sit through.  That's not what retrospective is for.  It is for listening to your team, identifying areas that cause the most pain and fixing them so that everyone can move on with their work.  Apparently software engineers in general like delivering products and features and the most important message retrospective meeting needs to communicate, is that it is solely for their benefit. You want to identify and tackle obstacles, starting with the biggest ones (or easiest ones, there's some kind of 2D map involved) and get them out of the way so your people get their work done.


问:
Are there any Web Frameworks for beginners?
I was wandering if there are any frameworks like Google Web Toolkit to create Web Apps? (Apps like Evernote, Spring Pad, Google Docs, etc.).

I am fluent in Java but could learn a new language without much problem. So is there any kind of framework that would allow me to write Web Apps without worrying much about UI element design and client-server communication?

I have heard of one-- Vaadin. Is it something like what I am looking for? If yes, are there any alternatives?

I'm hoping to make a Web App similar to this: Gantter. Mostly the UI and smooth usability.

答:
I think the OP is looking for a framework that will enable them to write the server code, and automatically generate the requisite Javascript and CSS. I'm not sure, (having never used either) but this sounds like a job for Ruby on Rails / .NET? I think the Yii framework does something like that too. You might want to turn the problem on its head and use Node.js and one of it's frameworks (i.e Matador).

Having said that, even with frameworks, web developers are generally required to know a server language, css, html, JavaScript, a SQL derivative...it's a long list. Most devs I know specialised in either UX (read js, css) or a server technology (PHP, python-django, ruby-on rails) at first. You may not find your holy grail even exists...


答:
Depending on the number of developers and modules (and timescales) I generally get my developers to pick one interesting module (to them) and one challenging module (preferably something they haven't done) and then the remainder I divide out by skill level and time constraints.  I find this gives my developers something they want to work on and something to push them.

Of course this doesn't always work ...


答:
Strictly speaking, if the 'inner' exception reveals anything about the inner workings of an implementation, you are leaking. So technically, you should always catch everything and throw your own exception type.

BUT.

Quite a few important arguments can be made against this. Most notably:

Exceptions are exceptional things; they violate the rules of 'normal operation' in many ways already, so they might as well violate encapsulation and interface-level abstraction as well.

The benefit of having a meaningful stack trace and to-the-point error information often outweighs OOP correctness, as long as you don't leak internal program information past the UI barrier (which would be information disclosure).

Wrapping every inner exception in a suitable outer exception type can lead to lots of useless boilerplate code, which defeats the entire purpose of exceptions (namely, implement error handling without polluting the regular code flow with error handling boilerplate).

That said, catching and wrapping exceptions often does make sense, if only to add additional information to your logs, or to prevent leaking internal information to the end user. Error handling is still an art form, and it's hard to boil it down to a few general rules. Some exceptions should be bubbled, others shouldn't, and the decision also depends on context. If you're coding a UI, you don't want to let anything through to the user unfiltered; but if you're coding a library that implements some network protocol, bubbling certain exceptions is probably the right thing to do (after all, if the network is down, there is little you can do to enhance the information or recover-and-continue; translating NetworkDownException to FoobarNetworkDownException is just meaningless cruft).


答:
First of all, what you're doing here is not rethrowing an exception. Rethrowing would be to literally throw the same exception, like this:

```<code>try {
    $SomethingInTheClass->doSomethingThatThrowsAnException();
} catch (Exception $Exc) {
    throw $Exc;
}
</code>```

Obviously, this is a bit pointless. Rethrowing is for circumstances where you want to release some resources or log the exception or whatever else you might want to do, without stopping the exception from bubbling up the stack.

What you are doing already is replacing all exceptions, no matter what the cause, with a DoohickeyDisasterException. Which may or may not be what you intend to do. But I would suggest that any time you do this, you should also do as you suggest and pass the original exception as an inner exception, just in case it is useful in the stack trace.

But this is not about leaky abstractions, that's another issue.

To answer the question of whether a rethrown exception (or indeed an uncaught exception) can be a leaky abstraction, I would say that it depends on your calling code. If that code requires knowledge of the abstracted framework then it is a leaky abstraction, because if you replace that framework with another then you have to change code outside of your abstraction.

For example, if DoohickeyDisasterException is a class from the framework and your calling code looks like this, then you have a leaky abstraction:

```<code>try {
    $wrapper->getThatDoohickey();
} catch (DoohickeyDisasterException $Exc) {
    echo "The Doohickey is all wrong!";
    echo $Exc->getMessage();
    gotoAHappyPlaceAndSingHappySongs();
}
</code>```

If you replace your third-party framework with another, which uses a different exception name, and you have to find all these references and change them. Better to create your own Exception class and wrap the framework exception in it.

If, on the other hand, DoohickeyDisasterException is one of your own making then you're not leaking abstractions, you should concern yourself more with my first point.

Body:
First of all, what you're doing here is not rethrowing an exception. Rethrowing would be to literally throw the same exception, like this:

try {
    $SomethingInTheClass->doSomethingThatThrowsAnException();
} catch (Exception $Exc) {
    throw $Exc;
}

Obviously, this is a bit pointless. Rethrowing is for circumstances where you want to release some resources or log the exception or whatever else you might want to do, without stopping the exception from bubbling up the stack.

What you are doing already is replacing all exceptions, no matter what the cause, with a DoohickeyDisasterException. Which may or may not be what you intend to do. But I would suggest that any time you do this, you should also do as you suggest and pass the original exception as an inner exception, just in case it is useful in the stack trace.

But this is not about leaky abstractions, that's another issue.

To answer the question of whether a rethrown exception (or indeed an uncaught exception) can be a leaky abstraction, I would say that it depends on your calling code. If that code requires knowledge of the abstracted framework then it is a leaky abstraction, because if you replace that framework with another then you have to change code outside of your abstraction.

For example, if DoohickeyDisasterException is a class from the framework and your calling code looks like this, then you have a leaky abstraction:

try {
    $wrapper->getThatDoohickey();
} catch (DoohickeyDisasterException $Exc) {
    echo "The Doohickey is all wrong!";
    echo $Exc->getMessage();
    gotoAHappyPlaceAndSingHappySongs();
}

If you replace your third-party framework with another, which uses a different exception name, and you have to find all these references and change them. Better to create your own Exception class and wrap the framework exception in it.

If, on the other hand, DoohickeyDisasterException is one of your own making then you're not leaking abstractions, you should concern yourself more with my first point.


问:
What are the features required for Object Orientation?
I am just wondering, what exactly are the features a language or a library must provide in order for it to be defined as 'Object Oriented'. Is Object Orientation something that can, more or less, be achieved in any general-purpose programming language with decent features? Or is it something that can only be achieved in languages that specifically advertise that they support Object Oriented Programming?

For example, look at the following C code:

```<code>SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_HWSURFACE);
SDL_FreeSurface( screen );
</code>```

or the code discussed here.

Now the above code does not use inheritance , runtime-polymorphism ( ? ) , virtual functions etc. But it seems pretty much OOP to me.

Is Object-Orientation simply writing code which is based on creatable and destructable data structures such as objects, classes, structs etc. which does not require on any special pattern or features provided by the Programming Language or a library ?

答:
Object orientation is defined as

Polymorphism

Inheritance

Encapsulation

also check out wikipedia entries. those are the features a language must provide for it to be defined as object oriented.

consider your code object oriented if it is in a object oriented programming language. even if you write something that appears to be procedural it will be acting upon methods in objects from classes using polymorphism via encapsulation [maybe] :)

regarding your last question the answer is probably. yes. object oriented is basically just acting on methods on objects and passing around those objects as parameters.


问:
What's stopping Oracle from supporting identity (auto-numeric) columns?
EDIT: As gavenkoa's answer points out, Oracle Database 12c (released a couple of years after this question was asked) has support for Identity Columns.

As far as I know, Oracle's RDBMS is one of the few (the only?) SQL database products that doesn't support identity/autonumeric columns.

The alternative offered by Oracle is database sequences, a feature in many ways much more powerful than auto-numeric columns, but not equivalent.

It is not that I don't like sequences. What I hate is having a different programming model for generating row identity values between Oracle and any other database. For example, I often try to setup HSQL or SQLite for java apps that will eventually run over an Oracle database when I'm not working specifically on the data layer (just as a stub or mocking database). I cannot do that easily because I need different set of SQL DDL scripts: one for Oracle, and one for everyone else; I also need two sets of Hibernate mapping files if I'm using Hibernate.

What I find intriguing is that Oracle Database, being one of the most complete and robust enterprise software packages of the last decade hasn't put that seemingly basic feature in their product, but almost any other RDBMS, even the smaller ones, has it.

Why?

Why doesn't oracle support a sequence-based identity column shortcut syntax that dumb and lazy people like me can use?

The only reason I can think of is that Oracle does that on purpose as a vendor lock-in strategy so your code is harder to migrate to other RDBMS where your database sequences cannot be used.

Or maybe I'm just wrong and confused? Please enlighten me.

答:
I'm only guessing here but its probably for legacy reasons.

Sequences & identity columns have annoying properties like not respecting transactions. Sequences actually provide you with more flexibility than a plain identity column as it allows you, the developer, to decide how and when to apply the sequence.

Sequences also give you the ability to know your assigned sequence number before having to insert the record.

On a side note, if you plan in the future to support either replication or any form of disconnected'ness (eg mobile devices or offline connections to your database) i would suggest using GUIDs as your key. As this removes issues around sequence partitioning etc.


答:
When I was a student I was taught that object-oriented programming stands on three pillars:

encapsulation,

polymorphism, and

inheritance.

A language will have to support those features in order to be considered an object-oriented language.

Note that this describes a set of features, rather than syntax. Hence, whether you have to write

```<code>type obj; // or type obj = new type;
obj.func(arg);
</code>```

or

```<code>type* ptr = create_type();
func(ptr, arg);
</code>```

doesn't matter.

So you can indeed program according to the object-oriented paradigm in C. But the language offers no support for this, which makes it a rather painful exercise. This is why C is not considered an object-oriented language.

Title: What are the features required for Object Orientation?

Body:
I am just wondering, what exactly are the features a language or a library must provide in order for it to be defined as 'Object Oriented'. Is Object Orientation something that can, more or less, be achieved in any general-purpose programming language with decent features? Or is it something that can only be achieved in languages that specifically advertise that they support Object Oriented Programming?

For example, look at the following C code:

```<code>SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_HWSURFACE);
SDL_FreeSurface( screen );
</code>```

or the code discussed here.

Now the above code does not use inheritance , runtime-polymorphism ( ? ) , virtual functions etc. But it seems pretty much OOP to me.

Is Object-Orientation simply writing code which is based on creatable and destructable data structures such as objects, classes, structs etc. which does not require on any special pattern or features provided by the Programming Language or a library ?

Body:
When I was a student I was taught that object-oriented programming stands on three pillars:

encapsulation,

polymorphism, and

inheritance.

A language will have to support those features in order to be considered an object-oriented language.

Note that this describes a set of features, rather than syntax. Hence, whether you have to write

type obj; // or type obj = new type;
obj.func(arg);

or

type* ptr = create_type();
func(ptr, arg);

doesn't matter.

So you can indeed program according to the object-oriented paradigm in C. But the language offers no support for this, which makes it a rather painful exercise. This is why C is not considered an object-oriented language.


答:
You can do OO in any decent general-purpose language.

It's easier to do it in an "OO" language, because you have idiomatic constructs available and don't have to resort to something like OO in C - which is  possible, but horrible.

Whether the OO constructs are provided by the language itself, by its standard library, or by some other library, doesn't matter much, as some languages (e.g. Scala) allow libraries to add language constructs so that from the programmer's viewpoint it's almost impossible to distinguish which things are provided by the core language and which by a library.


问:
At what point should I have my Windows developers upgrade to the latest release of Windows?
At what point should I begin upgrading our developer's machines to a later Windows release?

From experience, Microsoft typically has an epic fail about every other O.S. (I am really not trying to start a debate about this, it is my perception let it be) i.e. 2000 was a stable and useful O.S, yet m.e. didn't do well, xp was a great O.S. that many businesses still use, Vista didn't do well (I know that the reason this one didn't do well wasn't really Microsoft's fault and that Vista and 7 are the same major revision), while 7 seems to be an excellent O.S. that will be around for a while--sort of like xp is now.

Anyways, this makes me reluctant to upgrade our development machines to Windows 8.

a. I don't want to cost our business a ton of money for an O.S. that
will only be used for a year or two.

b. They also have to have linux dual boots, and I have read that Windows 8 and grub will not play well together.

I do want our developers to develop in the latest environment and to have a leading edge in any technology they are developing with. I do want to stay ahead of--or at least with--the technology curve, yet I want it to make business sense.

So in particular, should I upgrade their machines at this point?
In general, what calculus should I use for deciding this sort of thing?

edit

They do write desktop UI applications as well as ASP.NET applications. Also, I do make sure that they always have the latest release of Visual Studio.

答:
Return on Investment is something very important. If you're working with Widows 7, you're good to go. Few things I have noticed with Windows 8 are

It's an optimized version of Windows 7 as usual.

The memory management has been considerably improved. Check Windows Engineering Blog

The core operating system is similar and WinRT is something new in this platform which enables Metro Style apps.

Faster boot. Yeah it's extremely fast.

Windows 8 is more focused on Tablet PCs. PCs sales are considerably reduced last year and people are eyeing on tablets like iPad. As a software company, Microsoft has focus on this paradigm shift and address the low configuration form factors. For a developer perspective, it doesn't make much difference as long the new unique features are exploited. Unlike Apple, Microsoft OS upgrade is too expensive.


答:
My understanding of OO is that OO is a way of thinking and an implementation that is based on the idea that a computational task can be achieved by one worker(object) or by collaboration of individual workers (objects) via message passing between those workers(objects) at run-time. This run-time behavior requires solid static, and dynamic constructs to enable it.

The specific syntax to implement OO is not the key that determines whether a language is an OO or not. For example, Smalltalk and C# have different syntaxes but both are OO languages (to a varying degrees).  The key is whether the given language preserves the philosophy (above) and provides the implantation means required.


答:
According to Alan Kay, who invented the term "object oriented",

OOP to me means only messaging, local retention and protection and
  hiding of state-process, and extreme late-binding of all things. It
  can be done in Smalltalk and in LISP. There are possibly other systems
  in which this is possible, but I'm not aware of them.

Messaging (as implemented in Smalltalk) is a comparable concept to polymorphism, but rather more powerful (at least than the kind of polymorphism supported by C++ or Java). It can be done in all languages, but is rather painful if not supported directly by the language. Basically it means objects can send each other messages containing anything, amd can react however they want to messages they receive. To fully support messaging, there must be a way for objects to react flexibly to messages without enumerating them in the source code (which is basically what method/function definitions do).

local retention and protection and hiding of state-process - AKA encapsulation - can be done by convention in all languages, but that's cheating somewhat. Local retention on the language level actually seems to be the one feature all languages that claim to be OO (and many that don't) share - there's generally a way to create compound datatypes with multiple instances. The protection and hiding, on the other hand, is often only done by convention.

late-binding of all things - a sliding scale on which C is really far away from Kay's vision (As is C++, while Java is much closer). Can be faked (see COM), but that will be a pain to use.

Note how Kay does not mention inheritance. In the same email he wrote

I didn't like the way Simula I or Simula 67 did inheritance (though I
  thought Nygaard and Dahl were just tremendous thinkers and designers).
  So I decided to leave out inheritance as a built-in feature until I
  understood it better


答:
Object-oriented programming is not about syntax features, it's a coding and design philosphy. At its core stands the concept of an object, which is a construct that groups state with routines to act upon it (or, depending on your point of view, responses to messages). The other important aspect of OOP is encapsulation: wrapping implementation details into opaque structures and connecting them through well-defined interfaces. Pretty much everything else in OOP theory goes back to these two fundamentals.

So, any language that can somehow model objects (entities that contain both data and code) and encapsulation can be used to do OOP. For example, in C you can use function pointers to store functions in structs, and you can use the header / source file system to realize encapsulation. It's not convenient, but it is enough to do OOP. You can probably even bend something like Haskell or ML into doing OOP, and I wouldn't be surprised if someone could come up with a way of doing OOP in assembly.

Practically speaking, though, a language can be called 'object-oriented' if it provides a complete set of syntax features for explicit object-oriented programming. Typically, this means that such a language should have:
* a notion of an object
* a notion of method calling or message passing
* a comfortable and straightforward way of controlling access to object members
* a comfortable and straightforward way of defining interfaces

Consequently, I'd call a piece of code object-oriented if it adheres to OOP principles and uses the available OOP syntax.

BTW., your code example probably does use polymorphism and virtual functions, although the C syntax doesn't make it obvious. I'm not an expert on SDL, but I'd expect an SDL_surface to be able to represent various different types of surfaces, each with its own specific set of implementations - blitting something onto a memory bitmap and blitting to a screen surface requires radically different code, but the interface (the functions that take an SDL_surface* as an argument) remains the same. Just like that, it also implements encapsulation: you can't access a surface's underlying representation directly, you have to go through functions that know how to handle an SDL_surface, because that's all you have. It's a nice example of how you'd do OOP in C.


问:
What's wrong in returning hashtable from public method and when does it make sense to do so?
What are the design problems in returning a hashtable from a public method when you want to return multiple items instead of creating a class and returning object of that?

If it does have problems then under what circumstances it makes sense to do so?

How does the answer to this question change depending upon whether the language is dynamic or not?

Edit: This is to clarify that the keys would be constant and are part of code, not data. Something that we typically create a class for. The question is why would it be wrong to use hashtable instead if creating a class indeed does seem to be the right choice.

答:
One of the problems would be that in many cases, the key for the hash table would be a string. So the consumers of the method would have to know before hand which keys to use to extract the data. This would give the potential for errors due to mispellings when accessing the data.

Another drawback is refactorability. If you decide later on to change the name of a member, you then have a bunch of magic strings that also need to change. It's a lot simpler to rename a class member using refactoring tools provided by most good IDE's. With a hash table you'd likely have to do a find/replace operation across all source files which could be problematic.

Lastly, you will lose compile time checking of the member access - both in terms of name and type. The latter is not such a problem if your hash table only contains one type of obejct, but if it contains many (even in the same hierarchy chain) you really want to leverage the type system of your language and get compile time checking there. In most IDE's you'll have some kind of intellisense/autocomplete features - these work by looking at the type system, but they wont be able to help you with hash table keys.

As for times when it would be appropriate to return a hash table (or other such collection of key value pairs), you would use this when both the values and the keys are not known at compile time. For example, if you have a method which parses a query string and returns the keys & corresponding values, a hash table would be a good choice. In this case you would also want to think about returning some kind of immutable or readonly hash table.

Edit - Most of the points raised in this answer cease to apply when you're talking about dynamic languages :)


答:
The simplest approach is often the best.

I would avoid dividing tasks into groups such as testing/log/UI/etc unless you can define some very good and clear reasons for doing so.  My reasoning is that when you allow programmers to work outside of their usual areas of expertise, it can keep things more interesting and challenging for them, and allow them to develop and grow within their field. If you do feel that time constraints require you to divide work based on expertise, at the very minimum ensure that each developer is still required to do their own unit testing, and use code review and acceptance testing to pick up problems. Writing your own tests is very agile, and waiting for testers time to become available can be very wasteful.

When faced with this same sort of dilemma, I have employed the following approach:

Scope the project. Give yourself an idea about what you're getting yourself into, and develop a list of features by breaking down the project into a series of tasks.

Prioritize Features. Decide which features must be completed early, and which will provide immediate value to your customers. Don't worry if your developers end up working on the same modules, but make sure you have a good process and tools to manage code merges.

Get your team involved, and ask your developers to aid you in breaking down the features into a list of more easily managed tasks.  Review as a group and adjust tasks as needed so that they can be more easily estimated.

Ask each developer to choose a task to implement - or a group of tasks depending on how your iterations are going to run - from the top of the priority queue, which the developer would like to work on.

Have each developer work on only one thing until it is completed before moving on to selecting the next item from the top of the priority queue.  You may be tempted to have your people change tasks occasionally, however this will lead to waste in terms of the developer's time.  If you find yourself with dependency bottlenecks, you will need to adjust your task priorities and minimize the waste.

Don't be afraid to have developers running with overlapping iterations, and manage your releases accordingly.  This will help minimize time wasted between releases waiting for tasks to be completed.

Ultimately, being Agile is about finding a solution that works well for your team, your company, and your customers. It's up to you to tune your process by finding the balance of practices that will work best for you. How to divide your tasks is going to be a very important part of a much larger process, but should be kept as simple as you can make it to encourage willing participation, and to avoid difficult to solve process related problems developing later on.


答:
Don't think in modules. Think in functionality elements. Describe those functionality elements by user stories (or other way) and don't forget to describe acceptance criteria (probably defined by your current application and changes the business expect). Put your functional elements into backlog. Then let business prioritize which functionality must be delivered first (you will work incrementally and iteratively and priority will tell you what must be implemented first).

Once you have this at least for part of your original application you are ready for development. What happens next depends on your selected agile methodology. The important part is that each functionality can be usually divided into multiple tasks and team members will select what tasks they want to do - that is called self organization. When you are starting with agile, self organization may need some help where somebody will make sure that unpopular and popular tasks are equally shared by the team. Once the team is more mature, developers will not hesitate to speak their disagreement with the current self organization and this will be handled automatically inside the team.

Thinking in modules from start doesn't have to be a good way. You are rewriting the application for some reason and maybe the current application architecture based on incorrect module separation is one of hidden reasons behind visible problems. Also you can find that some functionality from existing modules will be completely redefined and moved elsewhere.


答:
The most important argument against this would be that you are exposing too much information to the consumer. The consuming code only needs to know that it's a key-value collection (dictionary) of some sort; whether it's implemented as a hashmap, an association list, a trie, or whatever, is relatively uninteresting. So the proper way would be to return by a suitable interface (IDictionary, or whatever your language of choice uses) instead of by actual type.

All this assuming that you actually need a dictionary to represent your data, that is, your data consists of key/value pairs, where the keys are unique among the dataset, and cannot be fixed at compile time. If you have pre-known keys, you should be creating a proper type (or several, as required) for your data. It comes down to whether you regard the keys themselves as part of the data, or part of the code.

EDIT:

To clarify, I'm using the term dictionary to mean the most generic type of key-value data structure here; I don't mean any language-specific implementation such as Python's dict or .NET's Dictionary.

Title: What's wrong in returning hashtable from public method and when does it make sense to do so?

Body:
What are the design problems in returning a hashtable from a public method when you want to return multiple items instead of creating a class and returning object of that?

If it does have problems then under what circumstances it makes sense to do so?

How does the answer to this question change depending upon whether the language is dynamic or not?

Edit: This is to clarify that the keys would be constant and are part of code, not data. Something that we typically create a class for. The question is why would it be wrong to use hashtable instead if creating a class indeed does seem to be the right choice.


问:
Advantages of Scrum for the developers themselves?
Scrum being a project management methodology, how would you 'sell' it to the developers in a team that is reasonably happy with its current situation?

It seems easy to me to explain to our Product Manager how Scrum will allow him to get regular releases, to amend requirements, and get the team to focus on the high-priority stories first.  I found it easy to explain what TDD or Continuous Integration bring in a developer's day-to-day life.

But how can developers be convinced to embrace Scrum?  How would Scrum make their life easier?

答: Breaking the big goal ("get the software done") into smaller pieces - stories - and deciding which of them to do at the current sprint improves productivity and reduces stress. When you know specifically what you're supposed to be doing now, there's little to stress about, and you can focus on doing the little piece instead of feeling overwhelmed by the large whole.


问:
Does any software come with a warranty?

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, [blah
  blah blah].

It's everywhere. Is there any software which expressly comes with warranties which can be taken seriously? That is:

Provided by a group/company which has the resources to handle warranty claims, not uncle Bob.

Assures something "useful," such as ACID or ISO-whatever compliance, not protection from meteor impacts.

答:
I'm pretty sure there are examples of software that provide a warranty. Like for nuclear reactors... you know... to boost the confidence for the software that it won't cause a random meltdown.

Warranties are usually dealt per-project-projects because a client demands it, and less with a product-off-the-shelf.

Title: Does any software come with a warranty?


答:
Yes.

Some applications (medical, nuclear technology, aircraft) actually require warranties, and rightfully so, so any software made for these fields typically comes with an explicit warranty.

Custom software also usually comes with some kind of agreement regarding performance and reliability.

Furthermore, in some jurisdictions default law mandates a minimum warranty for software, and this warranty is valid even if explicitly denied. For example, in the Netherlands it is illegal to sell products (not just software, but any kind of product) that are not useful for any purpose, so the usual "fitness for a particular purpose" clause is generally void in the Netherlands.

Title: Does any software come with a warranty?

Body:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, [blah
  blah blah].

It's everywhere. Is there any software which expressly comes with warranties which can be taken seriously? That is:

Provided by a group/company which has the resources to handle warranty claims, not uncle Bob.

Assures something "useful," such as ACID or ISO-whatever compliance, not protection from meteor impacts.


答:
Usually commercial software with complex EULAs also have in the EULA some kind of warranty. It depends on the provider / creator / company of the software.

However, free and open source software, expecially GPL software comes without any warranty, in fact, what you quoted is part of the GPL license (section 15. Disclaimer of Warranty.). GPL also allows any company / person to offer warranty for a fee. You can read the GPL license here: http://www.gnu.org/copyleft/gpl.html

Title: Does any software come with a warranty?


答:
Alot of the vendor software in our industry (utility provider) seems to come with a contingency that it will do the job accordingly, if we agree to paying for a support contract.  Seems that most vendors are unwilling to take a risk on their code, without securing your cash upfront.  In some cases, the product may not do the job it was meant for, but lines like

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, [blah blah blah].

are designed to protect the vendor from situations where their product just plain does not work in an environment.  Its a lot easier than saying

We guarantee that our product will address this exact issue, at this exact time, if you are located in this time zone, and your infrastructure is setup like.....

It allows them to charge exorbitant contracts in the business environment. On the home user side, it allows software vendors to not be responsible for users incorrectly purchasing software, and attempting to install and register, and then taking action against the company if their system will not run it.

So to get to the point, I have not seen a valid use of a warranty for software, that was not dependent on a service contract. Not saying they do not exist, just that I have yet to see them.

Title: Does any software come with a warranty?


问:
How can I obtain feedback from external developers?
One of our external devs is leaving after successfully completing a short (1 month) project which he was contracted for.

I'd like to get some feedback from him by doing an exit interview to find out what could be better in our organization and development process.

What sort of questions can I ask to get detailed feedback from him, and not just vague responses?

答:
The usual general questions would work.

How do you think the project went?

Would you continue to work with the software if you were given the opportunity? If no, how so?

I'd be probing the guy with all sorts of questions using things like the Joel test as a basis for self reflection. You only need to ask the external developer on how you should deal with all the problem points or give suggestions to them. The points being:

How did source control work for you? Can we improve source control practices?

Are you happy with our build process? Are there ways to improve it?

Are you happy with the bug database? Did it work as intended?

Did the project schedule work? Was there any overtime that was unneccesary?

Was the spec enough? If no, what was missing?

Did you get a satisfiable working condition in the office.

Did you get all the things you needed to complete the project? Were you missing something?

How was your interaction with the testers? (BAs? PMs? Anyone else?)

What did you think of your co-workers, did you have any problem with any of them?

Can we improve our testing in some way?

Print out the questions as a questionare for yourself, with enough space to write between the questions. Bring it to the exit meeting as you will use it to take notes. Make sure you stress that the information you'll give will be confidential if he or she desires it. Usually, people only give up feedback under confidence.

Edit:

After some thinking, it seems like people take the concept of an exit interview to a hyperbole. The OP wanted to know how to get feedback from a contractor, thus the meeting shouldn't be called an exit interview or exit meeting due to the faulty connotation; it should instead be called a "feedback" interview instead.


答:
If you look at the range of languages which have been widely accepted as OO and those who haven't, the test seems to be the support for inclusion polymorphism (aka sub-type polymorphism, but inclusion polymorphism is the term used by Cardelli in the paper which introduced me, and I think quite a lot of others, to a classification of kinds of polymorphism). I.E. the possibility for some variables to have values of different types and the possibility for some calls to dispatch to different routines depending on the type of one or several values. Everything else has been present in languages not accepted as OO or been missing from languages well accepted as OO.

The two major other characteristics associated with OO languages have been provided by non OO languages:

Encapsulation is quite well provided by Ada83;

Inheritance is provided by Oberon (Oberon is interesting, Wirth wanted to provide an OO language with as less cruft as possible, but had to revisite his conception to get one -- Oberon-2 is OO).


答:
"what would you ask someone in this kind of situation?"

Absolutely nothing. I'll just say "good luck".

If he's exiting he may have no more interest in helping you (so he will rarely give you really meaningful answers)

It is not necessarily because something was wrong in you. My be he's just searching form something different that may be not in your business.

If you really want to improve your process, monitor the "massive escapes", and try guess where   did they go.
And try to learn how other are organized using informal relational networks, not formal process.

Title: How can I obtain feedback from external developers?

Body:
One of our external devs is leaving after successfully completing a short (1 month) project which he was contracted for.

I'd like to get some feedback from him by doing an exit interview to find out what could be better in our organization and development process.

What sort of questions can I ask to get detailed feedback from him, and not just vague responses?


问:
Authentication for 'participants' vs 'users'
I'm building a site that lets users schedule interviews/conferences with third parties and I'm wondering what's the best way to provide security around the participant experience while providing the smallest usability barrier possible.

Currently, I send an email with a link and a 5 digit auth-code. The link opens a page, the participant types in the auth-code and is temporarily logged in for the duration of the interview/conference.

From a security standpoint, I think the auth-code is redundant and introduces friction for the participant, who may never have cause to visit my site again and may not be technically proficient. The link I send as part of the invitation contains a random string, so I could just increase its length by 5 characters and have the same size search space for potential attackers.

The downside is that I would potentially have to rate-limit the responses for the invitation URLs, so I'm not sure there's any benefit from a complexity/lines-of-code perspective.

The non-auth-code feels less secure, but I know that's irrational. Any thoughts on what the best approach would be?

答:
having a 5 digit code they have to type in is nothing, its almost too short.  Its far better than my average experience with online meeting that generally require typing in a meeting id + potentially a password.

If your worried about the tech savyness of a user the password is the least of your problems, if they can use their webcam/mic to conduct the interview they can handle a password.

Nothing is going to ruin your site faster than people getting in to interviews/conferences they don't belong in, so erring on the side of security is a good thing.


问:
What do you consider to be the prime cause of software defects (and how to minimize them)
I define defect as :

"something within the application design or code which prevents it functioning as per requirements."

I'm looking for ideas about the causes of defects, eg the human factor, lack of testing, lack of prototyping, and possible ideas to mitigate these.

答: Writing code that fails silently vs. code that reports all errors.</p>


答:
What about encrypting the auth code in the querystring of the link instead, so then all they have to do is click the link to join?

In the past I've encrypted some kind of identifier field in the query string, and the page the link takes them to decrypts the id and checks it for things like if its for a valid session, and if the session is currently active. If it passes, it will take them to their session. If not, display some kind of page telling them the link they used is invalid or expired.

Title: Authentication for 'participants' vs 'users'

Body:
I'm building a site that lets users schedule interviews/conferences with third parties and I'm wondering what's the best way to provide security around the participant experience while providing the smallest usability barrier possible.

Currently, I send an email with a link and a 5 digit auth-code. The link opens a page, the participant types in the auth-code and is temporarily logged in for the duration of the interview/conference.

From a security standpoint, I think the auth-code is redundant and introduces friction for the participant, who may never have cause to visit my site again and may not be technically proficient. The link I send as part of the invitation contains a random string, so I could just increase its length by 5 characters and have the same size search space for potential attackers.

The downside is that I would potentially have to rate-limit the responses for the invitation URLs, so I'm not sure there's any benefit from a complexity/lines-of-code perspective.

The non-auth-code feels less secure, but I know that's irrational. Any thoughts on what the best approach would be?


问:
How can I provide a limited warranty for a software product?
Software, unlike most physical products you can buy, is sold with as few warranties as the vendor can get away with. As a developer, this seems very reasonable considering the quality of almost all software I've ever used - Think anything from unintuitive idioms, via undocumented features, irreproducibility, missing handling of concurrency, double escaping of user input, and floating point numbers where decimals would avoid long-term build-up of errors, to plain crashing bugs where the production database is corrupted and the equivalent of several hirings in the affected company are wasted on recovery and reactionary implementation of safety measures. It's a bit like building skyscrapers out of straw and nitroglycerin, hoping it will survive until the time when it's someone else's problem or it's replaced entirely.

In such a situation, I hypothesize that a company which trusts their software enough to provide even minor warranties for damages incurred would (if their software was up to the task) gain an enormous advantage in user trust, and could put Google, Microsoft and Apple to shame for quality software and hoarding of money and talent.

I'm not familiar with the current status of software verification and requirements gathering research, so I don't know whether this possibility is just around the corner or whether we are hacking at the mountain with toothpicks. Certainly the existence of any serious company or organization at all providing such warranties or even working on guidelines for warranties would be extremely interesting to follow, as both a developer and user.

Therefore: Are there any international guidelines for providing software warranties?

Examples:

If all the tests succeed, as long as the system stays in a defined state, the warranty covers the cost of recovery in case of data loss.

As long as [some widely recognized set of security guidelines] are followed, the data handled by the system will not be readable by third parties. The warranty could cover anything from the price of the software to the legal costs of handling privacy-related lawsuits or more.

答:
You Have 2 basic kinds of software :

1) Off the Shelf, prepackage stuff - Usually The warranty for this covers only the cost of the software itself. It’s very similar to any other warranty. You buy it, it doesn't work, they will get it to work or refund your money. (Assuming they believe you.. you take MS office back to the store opened saying it won’t install, you will likely get "Sorry we don't take back open software" as a response)

2) Custom Software: This is basically the same as packaged software EXCEPT the duration of the Warranty is for a negotiated period of time (usually 3-6 month, or a outlined in a long term support contract), Any defect after that is outside the Warranty even if it’s clearly a defect. So it’s really up to the purchaser to do his diligence in testing during the "Acceptance Phase"

NOBODY COVERS THE COST OF DATA LOSS

It would be insane to. I sell you Inventory-tracker 2.6 for 50$, a Glitch causes you to "Loose" 100k in inventory. Should I be libel for that 100k? If yes, no one would sell software, it’s not worth the risk. Again.. it’s up to the purchases to do his diligence to insure the software is working as expected (Note the word Expected.. I did not say Designed.)

The customer has to backup his data. This is his protection against data loss.


答:
Regarding data loss: I took a look at some online backup systems. Here is one example:

entire liability, and Your exclusive remedy, for any and all claims arising under or in connection with this Agreement or related to any item or service provided under or in connection with this Agreement, regardless of the form of the action (including negligence), whether in breach of warranty, contract, tort, strict liability or otherwise, shall be limited to a maximum amount equal to the license and maintenance fees paid within the last six (6) month period prior to such loss. You expressly recognize and acknowledge that such limitation of liability is an essential part of this Agreement and is an essential factor in establishing the price of the Licensed Products. You shall cause your insurers of data, if any, to waive any right of subrogation against...

You have to limit what you will cover and what you will refund. Remember companies such as LL Bean and Lands End only refund the cost of the boots, and ignore the fact the hike wasn't fun in boots falling apart.

Title: How can I provide a limited warranty for a software product?

Body:
Software, unlike most physical products you can buy, is sold with as few warranties as the vendor can get away with. As a developer, this seems very reasonable considering the quality of almost all software I've ever used - Think anything from unintuitive idioms, via undocumented features, irreproducibility, missing handling of concurrency, double escaping of user input, and floating point numbers where decimals would avoid long-term build-up of errors, to plain crashing bugs where the production database is corrupted and the equivalent of several hirings in the affected company are wasted on recovery and reactionary implementation of safety measures. It's a bit like building skyscrapers out of straw and nitroglycerin, hoping it will survive until the time when it's someone else's problem or it's replaced entirely.

In such a situation, I hypothesize that a company which trusts their software enough to provide even minor warranties for damages incurred would (if their software was up to the task) gain an enormous advantage in user trust, and could put Google, Microsoft and Apple to shame for quality software and hoarding of money and talent.

I'm not familiar with the current status of software verification and requirements gathering research, so I don't know whether this possibility is just around the corner or whether we are hacking at the mountain with toothpicks. Certainly the existence of any serious company or organization at all providing such warranties or even working on guidelines for warranties would be extremely interesting to follow, as both a developer and user.

Therefore: Are there any international guidelines for providing software warranties?

Examples:

If all the tests succeed, as long as the system stays in a defined state, the warranty covers the cost of recovery in case of data loss.

As long as [some widely recognized set of security guidelines] are followed, the data handled by the system will not be readable by third parties. The warranty could cover anything from the price of the software to the legal costs of handling privacy-related lawsuits or more.


答:
I don't know a lot about this but I know that, for custom software (not off-the-shelf), many development teams require the client to use specific hardware in order for the warranty to be valid. You can look into that if you think it's reasonable for your particular case.

Also, sometimes warranties and performance guarantees are invalidated if the software is used with any product not provided or approved by the company who made that software.

I think the variety of situations when it comes to something like this is huge. It all comes down to how you draft the contract.


答: One question I'd ask myself is "are the keys changing in this dictionary?" If they are constant then you should return an object or other appropriate data structure. If they are dynamic then you might want to return some sort of dictionary style structure. Finally, if there are some keys that are going to be constant and some unknown set of dynamic keys, you might wish to return a hybrid data structure including some fixed values and some sort of dictionary for the overflow.</p>


问:
Is a programmer supposed to be self-sufficient?
At my current workplace, we don't have any testers, the rationale for that from the management being: "if we had testers, you wouldn't test your own code at all". This kind of thinking seems to be detrimental to product quality, as while I do test my own code, there are a lot of things that I will miss just for the fact that I know the system inside out and don't know how to use it "wrong". Black box testing doesn't really work as I subconsciously avoid the pitfalls that a dedicated tester would fall into. A lot of my time goes into fixing bugs that have slid into production code and found by the end user.

The system in question is large but is developed solely by me. This has also caused some managemental duties to fall on my lap, such as defining schedules and working on specifications.

Should these kind of tasks be my responsibility? I see myself strictly as a programmer and nothing else. And if these are my responsibility, to what extent? When is a project so large that it requires testers? Should a programmer have to refine the specification, worry about management of the project or even provide customer support?

Note

Some might have got the impression that I am against widening my responsibilities – that is not the case, I'm eager to get a role that involves more management duties, but currently it is not in my job description. Until I'm officially employed as such or the additional duties start showing in my paycheck, I'm going to think of myself as 'just' a programmer. Unfortunately, as a junior developer, shifting to managerial duties is not going to happen very soon.

Excellent answers so far, keep them coming if you have something to add or personal experiences to share!

答:
Yes. If you have to, you should be able to test your code. (I'm not talking unit tests, but acceptance tests and such.)

No. Testers are better at testing than you are. And as you point out, just like proofreading, it's very hard to spot your own mistakes. Having extra eyeballs will have a major (good) impact on your program quality.

You have a lot of other questions. I'll only answer one:

Should a programmer have to refine the specification?

Yes! You have to implement the specification, so you have to ensure that the specification is actually implementable. Also, as a programmer - trained in clear thinking, precision and such - you can help people discover what actually needs to be done, and weed out ambiguous or logically flawed requirements.


问:
Is coupling with strings "looser" than with class methods?
I'm starting a school group project in Java, using Swing.  It's a straightforward GUI on Database desktop app.

The professor gave us the code from last year's project so we could see how he does things.  My initial impression is that the code is far more complicated than it ought to be, but I imagine programmers often think this when looking at code they didn't just write.

I'm hoping to find reasons why his system is good or bad.  (I asked the professor and he said I'd see later on why it's better, which doesn't satisfy me.)

Basically, to avoid any coupling between his persistable objects, models (business logic), and views, everything is done with strings.  The persistable objects that get stored in the database are hashtables of strings, and the models and views "subscribe" to each other, providing string keys for the "events" they subscribe to.

When an event is triggered, the view or model sends a string to all of its subscribers who decide what to do for that event.  For instance, in one of the views action listener methods (I believe this just sets the bicycleMakeField on the persistable object):

```<code>    else if(evt.getSource() == bicycleMakeField)
    {
        myRegistry.updateSubscribers("BicycleMake", bicycleMakeField.getText());
    }
</code>```

That call eventually gets to this method in the Vehicle model:

```<code>public void stateChangeRequest(String key, Object value) {

            ... bunch of else ifs ...

    else
    if (key.equals("BicycleMake") == true)
    {
                ... do stuff ...
</code>```

The professor says that this way of doing stuff is more extensible and maintainable than having the view simply call a method on a business logic object.  He says there is no coupling between the views and models because they don't know of each others' existence.

I think this is a worse kind of coupling, because the view and model have to use the same strings in order to work.  If you remove a view or model, or make a typo in a string, you get no compile errors.  It also makes the code a whole lot longer than I think it needs to be.

I want to discuss this with him, but he uses his industry experience to counter any argument that I, the inexperienced student, might make.  Is there some advantage to his approach that I'm missing?

To clarify, I want to compare the above approach, with having the view be obviously coupled to the model.  For instance, you could pass the vehicle model object to the view, and then to change the "make" of the vehicle, do this:

```<code>vehicle.make = bicycleMakeField.getText();
</code>```

This would reduce 15 lines of code that are currently ONLY used to set the make of the vehicle in one place, to a single readable line of code.  (And since this kind of operation is done hundreds of times throughout the app, I think it would be a big win for readability as well as safety.)

Update

My team leader and I restructured the framework the way we wanted to do it using static typing, informed the professor, and ended up giving him a demo.  He's generous enough to let us use our framework as long as we don't ask him for help, and if we can keep the rest of our team up to speed -- which seems fair to us.

答:
I think you have a good point, the magic strings are bad. Someone on my team had to debug a problem caused by magic strings a couple weeks ago (but it was in their own code that they wrote so I kept my mouth shut). And it happened... in industry!!

The advantage to his approach is that it might be faster to code, especially for small demo projects. Disadvantages are that it is prone to typos an the more often the string is used the more chance a typo code screw things up. And if you ever want to change a magic string, refactoring strings is harder than refactoring variables since refactoring tools might also touch strings that contain the magic string (as a substring) but are not themselves the magic string, and should not be touched. Also, you might need to keep a dictionary or index of magic strings so new developers won't start inventing new magic strings for the same purpose, and won't waste time looking up existing magic strings.

In this context, it looks like an Enum might be better than magic strings or even global string constants. Also, IDEs will often give you some sort of code-assist (auto-complete, refactor, find-all-references, etc...) when you use constant strings or Enums. An IDE won't offer much help if you use magic strings.


答:
enums (or public static final Strings) should be used instead of magic Strings.

Your professor doesn't understand OO. For example having a concrete Vehicle class?
 And to have this class understand the make of a bicycle?

Vehicle should be abstract and there should be an concrete subclass called Bike. I would play by his rules to get a good grade and then forget his teaching.

Title: Is coupling with strings "looser" than with class methods?

Body:
I'm starting a school group project in Java, using Swing.  It's a straightforward GUI on Database desktop app.

The professor gave us the code from last year's project so we could see how he does things.  My initial impression is that the code is far more complicated than it ought to be, but I imagine programmers often think this when looking at code they didn't just write.

I'm hoping to find reasons why his system is good or bad.  (I asked the professor and he said I'd see later on why it's better, which doesn't satisfy me.)

Basically, to avoid any coupling between his persistable objects, models (business logic), and views, everything is done with strings.  The persistable objects that get stored in the database are hashtables of strings, and the models and views "subscribe" to each other, providing string keys for the "events" they subscribe to.

When an event is triggered, the view or model sends a string to all of its subscribers who decide what to do for that event.  For instance, in one of the views action listener methods (I believe this just sets the bicycleMakeField on the persistable object):

```<code>    else if(evt.getSource() == bicycleMakeField)
    {
        myRegistry.updateSubscribers("BicycleMake", bicycleMakeField.getText());
    }
</code>```

That call eventually gets to this method in the Vehicle model:

```<code>public void stateChangeRequest(String key, Object value) {

            ... bunch of else ifs ...

    else
    if (key.equals("BicycleMake") == true)
    {
                ... do stuff ...
</code>```

The professor says that this way of doing stuff is more extensible and maintainable than having the view simply call a method on a business logic object.  He says there is no coupling between the views and models because they don't know of each others' existence.

I think this is a worse kind of coupling, because the view and model have to use the same strings in order to work.  If you remove a view or model, or make a typo in a string, you get no compile errors.  It also makes the code a whole lot longer than I think it needs to be.

I want to discuss this with him, but he uses his industry experience to counter any argument that I, the inexperienced student, might make.  Is there some advantage to his approach that I'm missing?

To clarify, I want to compare the above approach, with having the view be obviously coupled to the model.  For instance, you could pass the vehicle model object to the view, and then to change the "make" of the vehicle, do this:

```<code>vehicle.make = bicycleMakeField.getText();
</code>```

This would reduce 15 lines of code that are currently ONLY used to set the make of the vehicle in one place, to a single readable line of code.  (And since this kind of operation is done hundreds of times throughout the app, I think it would be a big win for readability as well as safety.)

Update

My team leader and I restructured the framework the way we wanted to do it using static typing, informed the professor, and ended up giving him a demo.  He's generous enough to let us use our framework as long as we don't ask him for help, and if we can keep the rest of our team up to speed -- which seems fair to us.


答:
The approach your professor proposes is best described as stringly typed and is wrong on almost every level.

Coupling is best reduced by dependency inversion, which does so by a polymorphic dispatch, rather than hardwiring a number of cases.


答:
Let's be quite clear; there is inevitably some coupling in there. The fact that there is such a subscribable topic is a point of coupling, as is the nature of the rest of the message (such as “single string”). Given that, the question then becomes one of whether the coupling is greater when done via strings or types. The answer to that depends on whether you're concerned about coupling that is distributed over time or space: if the messages are going to be preserved in a file before being read in later, or are going to be sent to another process (especially if that's not written in the same language), using strings can make things much simpler. The downside is that there is no type checking; blunders won't be detected until runtime (and sometimes not even then).

A mitigation/compromise strategy for Java can be to use a typed interface, but where that typed interface is in a separate package. It should consist of just Java interfaces and basic value types (e.g., enumerations, exceptions). There should be no implementations of interfaces in that package. Then everyone implements against that and, if conveying the messages in a complex way is necessary, a particular implementation of a Java delegate can use magic strings as necessary. It also makes it much easier to migrate the code to a more professional environment such as JEE or OSGi, and greatly assists little things like testing…


答:
Using 'industry experience' is a poor argument.  Your professor needs to come up with a better argument than that :-).

As others have stated, the use of magic Strings is certainly frowned upon, using enums is considered far safer. An enum has meaning and scope, magic strings do not. Aside from that, the manner in which your professor is decoupling concerns is considered to be an older and more fragile technique than used today.

I see that @backtodos has covered this whilst I was answering this, so I'll simply add my opinion that using Inversion of Control (of which Dependency Injection is a form, you'll run across the Spring framework in industry before to long...) is considered a more modern way to deal with this type of decoupling.


问:
Build Process for Web Application
I have a web application with lots of Javascipt and CSS code. I want to minify the CSS and JS code using something like UglifyJS.

However, I don't want to program with the minified code and I want my team to checkout only the non-minified code. What's the most common way of doing this?

I guess you would push both the minified and non-minified code and have the code reference only minified files. Do most people create a file call BUILD that runs all JS/CSS files through the minifier? Programmers would then have to run the BUILD script before pushing right?

答: More or less. It is probably more common to use (instead of a custom BUILD shell script) make or Ant and let Jenkins deal with running the builds and deploying to an integration server.</p>

Title: Build Process for Web Application


答:
Yes, the build script is usually used to minify CSS and JavaScript code into two files.

You run it:

before tests (unless you're 100% sure that a solution which works with original code will also work with minified code. With CSS, it's easy. With JavaScript, if you use for example Closure Compiler with Advanced optimization, be ready to be surprised).

when deploying the application.

You don't run it:

when committing source code changes to version control (in all cases, there are no reasons to have minified files under version control).

each time you, as a developer, make a small change to the code in development environment. Otherwise, it would be too cumbersome.

Title: Build Process for Web Application

Body:
I have a web application with lots of Javascipt and CSS code. I want to minify the CSS and JS code using something like UglifyJS.

However, I don't want to program with the minified code and I want my team to checkout only the non-minified code. What's the most common way of doing this?

I guess you would push both the minified and non-minified code and have the code reference only minified files. Do most people create a file call BUILD that runs all JS/CSS files through the minifier? Programmers would then have to run the BUILD script before pushing right?


问:
Can we develop ASP.NET MVC application with MySQL as the database?
I have mostly seen ASP.NET websites using MSSQL as database. Even I developed one some time ago. Why only MSSQL, when MySQL, a free alternative is available. So, the question is, IS it possible to integrate a MySQL database as easily as MSSQL with ASP.NET application or we need to use some API for doing so ??</p>

答: You can use MySQL with ASP.NET MVC, as everybody else has said before. The one thing that you will be losing is CLR Integration with SQL Server. It is nice to be able to write stored procedures in C# if you have complex calculations and that is something you can't duplicate by using MySQL. </p>


问:
Is there an alternative to bits?
Is there an alternative to bits as the smallest unit of data? Something that won't be only 0 or 1, but actually hold many possible states in between? Wouldn't it be more natural to store floats like that?</p>

答: Those are called qubits, and are used in quantum computers. You'll find more information about them on the wikipedia entry. Research is being done to make such computers that are stable and economically feasible.</p>

Title: Is there an alternative to bits?


答:
I think you could nowadays built items that could hold any amount of states or even work with analog data. Though building a whole system and getting all the logical components running to get a full featured and programmable architecture would be a lot of work and a financial risk for any company to undertake this task.

I think ENIAC was the last architecture to use ten-position ring counters to store digits. Though I could be wrong about this and I'm not sure, how much this influenced the other parts of the machine.

Title: Is there an alternative to bits?

Body: Is there an alternative to bits as the smallest unit of data? Something that won't be only 0 or 1, but actually hold many possible states in between? Wouldn't it be more natural to store floats like that?</p>


答:
There are also ternary computers instead of binary ones. http://en.wikipedia.org/wiki/Ternary_computer

A ternary computer (also called trinary computer) is a computer that uses ternary logic (three possible values) instead of the more common binary logic (two possible values) in its calculations...

Title: Is there an alternative to bits?


答:
You're basically describing an analog signal, which are used in sensors, but rarely for internal computations.  The problem is noise degrades the quality, you need very precise calibration of a reference point that is difficult to communicate, and transmission is a problem because it loses strength the farther it travels.

If you're interested in exploring analog computing, most undergrad "intro to electronics" classes have you build things like op-amp integrators.  They're easy enough to build even without formal instruction.

You can also store multiple digital states on the same node.  For example, instead of 0-2.5 volts being a zero and 2.5-5.0 volts being a one, you can add a third state in between.  It adds a lot of complexity, though, and significantly increases your susceptibility to noise.

Title: Is there an alternative to bits?


答:
Of course it is possible, both theoretically and practically.

Theoretically, there are two classes of alternatives: digital number systems with a base other than 2 (in fact, the decimal system as we know it is one such system); and non-digital number systems. Mathematically speaking, we're talking about discrete vs. continuous domains.

In practice, both options have been explored. Some of the early digital computers (e.g. ENIAC) employed decimal encodings rather than the now ubiquitous binary encoding; other bases, e.g. ternary, should be just as feasible (or infeasible). The esoteric programming language Malbolge is based on a theoretical ternary computer; while mostly satirical, there is no technical reason why it shouldn't work. Continuous-domain storage and processing was historically done on analog computers, where you could encode quantities as frequencies and / or amplitudes of oscillating signals, and you would then perform computations by applying all sorts of modulations to these signals. Today, quantum computing makes the theory behind continuous storage cells interesting again.

Either way, the bit as a theoretical smallest unit of information still stands, as any alternative can encode more information than a single yes/no, and nobody has yet come up with a smaller theoretical unit (and I don't expect it to happen anytime soon).

Title: Is there an alternative to bits?


答:
It might well be more natural to us but there are specific reasons why binary was chosen for digital circuitry and thereby for programming languages. If you have two states you only need to distinguish between two volt settings say 0V and 5V. For each additional increase to the radix (base) you'd need to further divide that range thus getting values that are indistinct from one another. You could increase the voltage range but that has this nasty habit of melting circuitry. </p>

<p>If you want to change the hardware type from digital circuitry your options are more varied. Decimals used to be used in mechanical computers since gears have much more heat tolerance and are much more distinct than electron charges. Quantum computers as stated elsewhere have other ways of dealing with things. Optical computers might also be able to do things we've not dealt with before and magnetic computers are a possibility as well. </p>

Title: Is there an alternative to bits?

Body:
It might well be more natural to us but there are specific reasons why binary was chosen for digital circuitry and thereby for programming languages. If you have two states you only need to distinguish between two volt settings say 0V and 5V. For each additional increase to the radix (base) you'd need to further divide that range thus getting values that are indistinct from one another. You could increase the voltage range but that has this nasty habit of melting circuitry.

If you want to change the hardware type from digital circuitry your options are more varied. Decimals used to be used in mechanical computers since gears have much more heat tolerance and are much more distinct than electron charges. Quantum computers as stated elsewhere have other ways of dealing with things. Optical computers might also be able to do things we've not dealt with before and magnetic computers are a possibility as well.


答:
Your professor is doing it wrong.  He's trying to completely decouple the view and model by forcing communication to travel via string in both directions (view doesn't depend on model and model doesn't depend on view), which totally defeats the purpose of object-oriented design and MVC.  It sounds like instead of writing classes and designing an OO-based architecture, he's writing disparate modules that simply respond to text-based messages.

To be somewhat fair to the professor, he is trying to create in Java what looks very similar to the highly common .NET interface called INotifyPropertyChanged, which notifies subscribers of change events by means of passing strings that specify which property has changed.  In .NET at least, this interface is primarily used to communicate from a data model to view objects and GUI elements (binding).

If done right, taking this approach can have some benefits¹:

The View depends on the Model, but the Model does not need to depend on the View.  This is appropriate Inversion of Control.

You have a single place in your View code that manages responding to change notifications from the model, and only one place to subscribe/unsubscribe, reducing the likelihood of a hanging reference memory leak.

There is way less coding overhead when you want to add or remove an event from the event publisher.  In .NET, there is a built-in publish/subscribe mechanism called events but in Java you would have to create classes or objects and write subscribe/unsubscribe code for each event.

The biggest downfall with this approach is that the subscribing code can fall out of sync with the publishing code.  However, this is also a benefit in some development environments.  If a new event is developed in the model and the view is not yet updated to subscribe to it, then the view will still likely work.  Likewise, if an event is removed, you have some dead code, but it could still compile and run.

In .NET at least, Reflection is used very effectively here to automatically call getters and setters depending on the string that was passed to the subscriber.

So, in short (and to answer your question), it can be done, but the approach your professor is taking is at fault for not allowing at least a one-way dependency between the View and Model.  It's just not practical, overly academic, and not a good example of how to use the tools at hand.

¹ Search Google for INotifyPropertyChanged to find a million ways people find to try to avoid using magic string when implementing it.


问:
Does your company have a coding standard?
I recently saw that Microsoft released a coding standards document (All-In-One Code Framework Coding Standards) and it got me thinking...  The company that I work for has no formal coding standards at all.  There are only a few developers and we have been together long enough to have evolved into similar styles and its never been an issue.

Does the company you work for have a documented coding standards?  If no, why not?  Does having a standard make a difference?  Is it worth writing a standard from scratch or should you adopt another standard as your own (ie. make Microsoft's standards yours)?

答:
Keep in mind that this is a coding standards document which is specific to the All-In-One Code Framework.

I have worked at various companies, some of which had an existing standard and some (most) of which I helped develop the standard. For the most part, if you are doing .NET based development (and even if you're not, most of the rules still apply) you should take a look at the Framework Design Guidelines. While this is specific to writing public facing APIs, most of the guidelines apply equally well to any code.

The biggest concern with code standards is to keep it relatively simple and straightforward. You want developers to be able to internalize the guidelines presented, so giving them a 50+ page document is useless. You can still create that document if you want to provide background, examples, etc. but you will also want something that boils down to a set of bulletted guidelines. Your coding standard also has to be a flexibile, living document that needs to change as technology changes.


问:
Is there an efficient way to adapt data from a structure to another in c++?
I'm writing an interface between two configuration models that use different structures. While I know that there is no "magic" way to do the translation from a structure type to another, I wandered if there might be some best practices or an efficient/effective way to setup such a system. I think it's similar to how programs may manage different configuration structures accross versions.

Here's a simple example: let's say we have a structure of type A which contains 3 parameters:

```<code>struct A {
  int alpha;
  bool beta;
  bool charlie;
};
</code>```

The second configuration structure share the same parameters, but in a different order, let's see structure B:

```<code>struct B {
  union {
    struct {
      char beta : 1;
      char charlie : 1;
    } bit;
    char field;
  }
  int alpha;
};
</code>```

A simple program to convert an A to a B would be:

```<code>void convert(A const *aelem, B *belem) {
      belem->alpha = aelem->alpha;
      belem->bit.beta = aelem->beta;
      belem->bit.charlie = aelem->charlie;
    }
</code>```

So, while this may seem fairly simple with such basic structures, I'm dealing with dozens of structures, each of one contains around 50 parameters. So do anybody knows of a good pattern to follow for such a problem ?

答:
Some of the later research into Remote Procedure Call optimization involved problems like this.  The only one I can both remember and find is Flux RPC. Those folks wrote a 1995 paper about optimizing RPC that might hold some interest for you.  If I recall correctly (I didn't re-read the paper), they had some serialization/marshalling code that did pretty much what you're talking about, and did it as fast or faster than hand-coded marshalling, like ONC RPC.

That said, I think your best bet is to bite the bullet and do it by hand.  It's pretty hard to parse C or C++ in the face of typedefs and macros and so forth, so unless you can scrounge up a struct parser, or maybe a system to read struct defs and write code to translate, you'll end up doing it by hand.  Be very organized.  Do as much mechanical checking as you can.  Even counting "to" and "from" elements and ensuring that counts match will catch some errors.


答:
A matter of accuracy

One reason we use bits is that it helps us store and retrieve information accurately.

The real world is analog, therefore all the information computers pass or store is ultimately analog. For example, a current of a specific voltage on a wire, or magnetic charge of a specific strength on a disk, or a pit of a specific depth on a laser disc.

The question is: how accurately can you measure that analog information? Imagine that a current on a wire could be interpreted as any decimal number, as follows:

1 to 10 volts: 0

10 to 20 volts: 1

20 to 30 volts: 2

Etc. This system would let us pass a lot of data in a few pulses of current, right? But there's a problem: we have to be very sure what the voltage is. If temperature or magnets or cosmic rays or whatever cause some fluctuation, we may read the wrong number. And the more finely we intend to measure, the greater that risk is. Imagine if a 1-millivolt difference was significant!

Instead, we typically use a digital interpretation. Everything over some threshold is true, and everything under is false. So we can ask questions like "Is there any current at all?" instead of "Exactly how much current is there?"

Each individual bit can be measured with confidence, because we only have to be "in the right ballpark". And by using lots of bits, we can still get a lot of information.

Title: Is there an alternative to bits?


问:
When should I use the XML data type in SQL Server?
When should I use the XML data type in Microsoft SQL Server?</p>

答:
I have used XML type fields mostly for logging purposes related to ASMX web services or WCF services. You can save the request or the response messages.

Most of the times, you save the XML in the DB for reference purposes - not for your regular business activity (not to query it every 5 seconds from the code). If you find yourself doing so, determine the fields that you usually query or use most of the time and create separate columns for them. That way, when you are saving the XML to the DB, you can extract these fields and save them to their corresponding columns. Later on while retrieving them you wouldn't need to query the XML document you can just use the columns you created for this purpose.

OwnerDisplayName: FarligOpptreden