问:
How to approach the ol' "this will just be a small application"? Yeah right?
Ok I have run into this many times, but here is the worse case scenario slightly exaggerated.

A client says "hey can you make us this small module to do this small task"?

Me: "Sure no problem".

So based on budgets and constraints etc., I skip some of the architecting and dive right in and make it no sweat.

Then they ask for another module. And another. And some enhancements. And this all happens very slowly mind you, over years. And before you know it, you have this monster application that is horribly architected.

What do you do when you are asked to do something small? You don't know if it will keep growing...if the client will keep asking for additions (and neither do they).

You can't over-architect the thing, because it's just a small application after all, and they will go somewhere else if you say (in that I know all voice) "Well just in case, let's architect this thing into layers with top-o-the-line security and separation of concerns. In fact let's go with a dependency injection tool that will really make this thing fantastic blah blah blah".

They will say "yeah right" and go to someone else.

Budget, time, and perception are as important as architecting the application itself.

How should this be approached?

I guess the question really boils down to "When you don't have all the information for the final outcome of what appears to be a small application, how do you avoid (or mitigate) making architecural and design decisions early on that will be completely innapropriate later?

答:
how do you avoid (or mitigate) making architecural and design
  decisions early on that will be completely innapropriate later?

You can't. Programmers aren't psychics. While we can predict simple things or see UI improvements, we can't really code beyond what we don't know the client might want later (do you see the insanity there?).

Your question mentioned that it had business processes but I'm not sure if they are good processes. Here's some pointers:

Require all changes and additions signed in writing and with a budget.

Because you have bills to pay

The writing and signed part make sure it's what they really want and cuts back on 90% of the frivileous things that clients change their minds on half-way during the project

Your Overgrown Product

It happens to all of us. Rebuilding from scratch usually is a terrible idea, especially considering it will be done again in the future.

Instead, I'd contract for the changes that the user asked for. Add extra time for each feature, using the original time to work on the feature, and the extra time to improve the overall architecture, one small improvement at a time. The goal isn't to completely "fix" the architecture in one contract, but instead to slowly chip at it over time.

Slowly improve the code iteration by iteration, focusing on the parts that really matter.


问:
Architectural differences between dynamic and static languages
Are there any major architectural differences when designing applications that will be built on static languages (such as C# or Java) and dynamic languages (such as Ruby or Python)?

Which are the design possibilities that might be a good choice for one type that's a bad one for the other? Are there any useful features achievable with one type that's not with the other (in design and architecture, of course)?

Also, are there any dynamic-specific design patterns?

答:
Are there any major architectural differences when designing applications that will be built on static languages (such as C# or Java) and dynamic languages (such as Ruby or Python)?

No.

It's slightly easier to write fancy frameworks for dynamic languages.  But that's not an application thing.

Which are the design possibilities that might be a good choice for one type that's a bad one for the other?

None, really.

You can write good things in either kind language.

Are there any useful features achievable with one type that's not with the other (in design and architecture, of course)?

No.

The difference is that dynamic languages are "write, run, fix".  You can experiment and fix quickly.

Static languages are "write, compile, build, run, fix".  You can't experiment as easily.

Other than that, they're nearly identical in their capabilities.

Are there any dynamic-specific design patterns?

Maybe.  The Python eval() and execfile() functions -- in a way -- point up a dynamic language feature that's difficult (but far from impossible) to handle in a static language.  It would be a lot more lines of code to compile and execute code in the same process space.

It's not dynamic-language specific.  It's just easier.

ContentLicense: CC BY-SA 3.0


问:
suggesting large changes/a rewrite as an intern
The context:

it's an internal project (that I don't think a lot of people use)

it's old

we're updating it

The issues:

it abuses the mvc framework (no use of models, business logic in views, etc)

what we're being asked to do is small, but because of the low cohesion we have two options:

continue to botch things

move large chunks of code around or rewrite the thing

The solutions (I see):

continue working with it, ignore best practices in favor of being done soon and not introducing new bugs by refactoring/rewriting

refactor/rewrite

I guess my question is really: if I want to make large changes to this project, how do I do propose that without insulting anyone? Or would it be better for me to simply go with the flow even if that means (metaphorical) duct-tape sometimes?

答:
As others have stated, ask another developer (one familiar with this application) to do a quick walkthrough just so you can understand the how/why of the implementation. Explain that while you can understand the technological aspects, but you want to be able to connect the dots to the business requirements (business requirements trumps all).

Once you have this information, you can then make your evaluation. If you personally think that it should be re-written, but don't think others will see it as a good use of time, take it on as a personal project. Even if it's an hour here/there when you have downtime, do the implementation "correctly". Once you finish, present it to the other developer(s) as a "hey, I felt like this could use some clean up, so i did some side-work during my downtime. what do you think?" Don't press the change on them - just offer it to them as a "hey, you guys like this?" and go from there.


问:
How can I sharpen my team player skills?
Currently I'm in my dream job in a research lab as the only developer in a multidisciplinary team. I'm getting a little bit worried because I'm forgetting about coding in a team (I don't have legacy code, I maintain my own code, I handle my own agenda, etc). Although I try to follow some of the the best practices like continuous delivery, TDD, and SCRUM just for me I think I'm losing my ability to work in a team of developers.

I've joined an open source project and began into the code katas and code golf. But these won't polish my team player profile.

What would be your suggestions to sharpen my team player skills?

Update: Yes, my communications skills are now better and I can talk to PhD's like never before. Like @Nicholas and  @Erick said, someday I will be facing a developing team (maybe in my current job, maybe not) and I want to keep current with those practices that makes a good developer a better team member, like pair programming or code review.

答:
I noticed that the times I most lost of my team player skills is working in a dysfunctional team where I am forced to deal with bad cases of Dunning-Kruger.  I discovered that with time I have less and less tolerance for people who think they've learned enough or that do not like their jobs.  Though with the latter I can sympathise so long as they do not become a nuisance for my own work.

When working alone for long periods of time I do long for a good team to interact with but I cannot say I am loosing team player skill. On the other hand better die alone than having to stand these pointy hair bosses one more day !

ok, now, enough ranting, back to work, pointy hair boss is coming around the corner !


问:
What is a Ph.D. good for in the software industry?
I'm a self-taught programmer and have just started a computer science degree to supplement my knowledge and fill in the gaps.

However, I'm already debating the direction of my education. I want a 4 year bachelor's degree for sure, but after that, I'm not sure: Is it worth it to get an M.Sc? What about a Ph.D.? What opportunities do these degrees open up?

Currently my goal is to be a software developer, but there are a number of fascinating fields in the software industry and I'm certainly interested in investigating many of them. It is in this respect that I think a higher degree may be worth it -- even if it wouldn't necessarily help a career of software development.

So will it be worth it? Will grad school open doors?

答:
Advanced degrees (MBA, MSC, etc (that is, et cetera - there's no ETC degree - AFAIK :-)) are useful and sometimes even necessary if you want to be a mid-level manager at a large (Fortune 500) company.  PhD's are necessary if your goal is to teach at the university level, or work at a research institute or at the research center of a large company, or if you want a piece of paper to hang on the wall to impress people with.

This is just the view from the center of the country - perceptions on the coasts may be different.  YMMV.

ContentLicense: CC BY-SA 2.5


答:
There is a significant architectural difference. Performance.

Depending on your hardware budget, expected workload and service level agreements it might not be possible to meet the requirements with a dynamic language.

Most often the speed of development and flexibility provided by dynamic languages offset the slower response times higher cpu and memory consumption. But for larger systems with budget or performance constraints the overheads of a dynamic language can be high.

Title: Architectural differences between dynamic and static languages

Body:
Are there any major architectural differences when designing applications that will be built on static languages (such as C# or Java) and dynamic languages (such as Ruby or Python)?

Which are the design possibilities that might be a good choice for one type that's a bad one for the other? Are there any useful features achievable with one type that's not with the other (in design and architecture, of course)?

Also, are there any dynamic-specific design patterns?


问:
What is the senior web developer's role in the team?
With a team of 3 other web developers i have the title as lead web developer for a year now. This is my first job as a lead.

I'm pretty set on what my roles are from management. I'm curious what other senior level developers do. I primarily curious as to what others people responsibilities are as the lead/senior developer in other organizations; as I've only encountered working in a small/medium company.

(a) What would one expect out of a senior / lead web developer of an organization (regardless of size)?

(b) Is there a difference between web development leader and senior web developer?

I reviewed some threads and there was just one that discussed when you should call yourself a senior developer but doesn't comprehensively discuss the roles of what a senior developer should do with his/her team.

答:
Project manager's point of view

You are the single (or default) point of contact for anything related to the technical side of things. You are expected to keep the work of the other developers' moving by sheer force, leading by example, or whatever your method is.

Not-lead developer's point of view

You are the role model. Expect the lesser-experienced developers to look up to you and to ask you technical questions when they're stuck.

Think

If you're really asking the internet to define your role/job, stop. Talk to management for a real answer.


答:
Let's get a few things straight:

Interactive scripting and static languages aren't mutually exclusive. F# and Haskell both have REPL interfaces.

Dynamic languages and high performance aren't mutually exclusive, though some optimizations are. JavaScript runs pretty damn fast on most browsers nowadays.

Even in dynamic languages, you still need to document, remember and think about types.

Due to the increasing popularity of type inference, a lot of static languages don't have to notate types very often anymore. In static languages with strong type inference, the compiler figures out what the types are from your code so that most of the time, and tells you if you ever do something that violates the type definitions. As far as syntax is concerned, this provides the best of both worlds.

OOP and dynamic languages aren't mutually exclusive. PHP now supports classes and even inheritance.

All those surprising similarities aside, there are some practical differences that do influence the development process:

Dynamic languages allow for interesting ways of passing data around in the small.

Static languages allow you to reduce the amount of testing you have to do by making many kinds of bugs impossible.

In that same vein, static languages allow interesting validation and automatic conversion features, like units of measure in F#.

Taken to the extreme, static languages allow for code contracts and formal verification, which can document and flat out prevent things like potential divide-by-zeros, infinite loops, null references, invalid list sizes or indices, range errors and other logically invalid state that you might define.

Taking that extreme even further, CPU optimizations can be made based on these static constraints, which yields even better performance.

There is also one type of program that could never have been made without static typing: Singularity, an OS without hardware process boundaries. It's written in a small amount of C, some C#, and a dialect of C# called Spec#, which supports code contracts.

Despite being written in a garbage-collected language, multitasking and interprocess communication performance on this OS is in fact better than anything else out there, due to the fact that all the processes run in one memory space, and due to the formal verification optimizations I mentioned above. You couldn't do this without static typing, because in order for programs not to be able to compromise the rest of the system, the communication objects need to be statically verifiable.

Most of the time, though, architectures should look very much the same. Static languages may make programs easier to reason about in many cases because the types are well-defined, but a well-written dynamic language program would also have types that are, at the very least, well-defined in the developers' minds.

ContentLicense: CC BY-SA 4.0


答:
There could be many different points of view, as Jonathan mentions above.

As a senior developer, you may set the architectural decisions for your group and act as your team's representative for higher-level development group meetings. You may also serve as a mentor and direct the technical activities of your team members.

Frequently, you may also be a liaison with both project management and the business users. You'll help decide how and when to deliver project deliverables and may have the opportunity to negotiate the priorities of project items over the longer term.

In short, your role is what you choose to make of it, given boundaries set by your own management (both technical and business-side).

Title: What is the senior web developer's role in the team?

Body:
With a team of 3 other web developers i have the title as lead web developer for a year now. This is my first job as a lead.

I'm pretty set on what my roles are from management. I'm curious what other senior level developers do. I primarily curious as to what others people responsibilities are as the lead/senior developer in other organizations; as I've only encountered working in a small/medium company.

(a) What would one expect out of a senior / lead web developer of an organization (regardless of size)?

(b) Is there a difference between web development leader and senior web developer?

I reviewed some threads and there was just one that discussed when you should call yourself a senior developer but doesn't comprehensively discuss the roles of what a senior developer should do with his/her team.


问:
What are the major differences when moving from console-based to GUI-based programming?
I started, like many others, with console-based (as in terminal, not Playstation) programming. But sooner or later, one needs to touch upon GUI-based programming, whether you want to or not. This transition holds many changes in how you need to think about the frontend (and possibly also the backend).

So, what are the major differences when moving from console-based programming to GUI-based programming?

答: I would say the multi-threading and it's implication with the UI (if you want to do non blocking UIs)</p>


答:
Well, let's explain... leadership.

All your team's mistakes are now yours to take blame of.

Same goes goes for the successes, but really, this is software development, success is modest, you will hardly have any problem in dealing with an excess of success.

Focus on those mistakes. Avoid them, minimize them, try to keep them in check.

And don't get bossy, your team does more mistakes if you do.


答:
OK Here goes.

You think the application is badly structured and badly written.

The customer thinks it does the job.

You want to rewrite it for no other reason than to improve its "internal beauty".

So you are asking the customer to spend money on getting the application to do exactly what it does now -- only the parts the user does not see or understand will be somehow "better".

The main objection to badly written badly structured code is that it is hard to understand.

The code is hard to understand and has functionality and features that can only be easily implemented in a badly structured application. So unless you are very very good at this the new application won't do exactly what the current application does, and, because you did not fully understand what the original code was doing it will probably be doing it wrong.

So your customer now has spent a lot of money to get an application that is markedly worse than the original application. You are not going to be popular!

Luckily your more experienced colleges are prepared to humor you (probably because they made the same mistake when they were starting out, and, may even have had the misfortune to get management approval for such an ill fated project).

So my advice would be to keep the old code base running, and, keep quiet. The customer just wants a system that works they do not really care if you think the code is ugly.

Title: suggesting large changes/a rewrite as an intern

Body:
The context:

it's an internal project (that I don't think a lot of people use)

it's old

we're updating it

The issues:

it abuses the mvc framework (no use of models, business logic in views, etc)

what we're being asked to do is small, but because of the low cohesion we have two options:

continue to botch things

move large chunks of code around or rewrite the thing

The solutions (I see):

continue working with it, ignore best practices in favor of being done soon and not introducing new bugs by refactoring/rewriting

refactor/rewrite

I guess my question is really: if I want to make large changes to this project, how do I do propose that without insulting anyone? Or would it be better for me to simply go with the flow even if that means (metaphorical) duct-tape sometimes?


问:
Programmer Ethics: Can I fork a project from one code host to another?
Say I find this great snippet of code on Bitbucket. I really, really like it but there's a small bug I want to fix. On the other hand, I have all of my code on GitHub.

Is it ok to start a new repo on Github and refer to the original by a comment or on the wiki?

答: The most ethical, from any point of view, would be to tell the author about the bug and eventually propse him/her the fix. Making a fork as you call it is nothing more than duplication and duplication in code should be avoided by all means. You could even call it a violation of the DRY principle.</p>


问:
Why were concepts (generic programming) conceived when we already had classes and interfaces?
Also on stackoverflow.com:

I understand that STL concepts had to exist, and that it would be silly to call them "classes" or "interfaces" when in fact they're only documented (human) concepts and couldn't be translated into C++ code at the time, but when given the opportunity to extend the language to accomodate concepts, why didn't they simply modify the capabilities of classes and/or introduced interfaces?

Isn't a concept very similar to an interface (100% abstract class with no data)? By looking at it, it seems to me interfaces only lack support for axioms, but maybe axioms could be introduced into C++'s interfaces (considering an hypothetical adoption of interfaces in C++ to take over concepts), couldn't them? I think even auto concepts could easily be added to such a C++ interface (auto interface LessThanComparable, anyone?).

Isn't a concept_map very similar to the Adapter pattern? If all the methods are inline, the adapter essentially doesn't exist beyond compile time; the compiler simply replaces calls to the interface with the inlined versions, calling the target object directly during runtime.

I've heard of something called Static Object-Oriented Programming, which essentially means effectively reusing the concepts of object-orientation in generic programming, thus permitting usage of most of OOP's power without incurring execution overhead. Why wasn't this idea further considered?

I hope this is clear enough. I can rewrite this if you think I was not; just let me know.

答:
Declaring a class is "programming objects".

Declaring a concept is "programming classes".

Of course, since always programming is, certain analogies can be seen, but the two things belong to a different phase of the abstraction process.
Basically a "class" (and everything is around it, like "interfaces") tells the compiler how to structure the objects that the executor machine will instantiate at runtime.
A "concept" is meant to tell the compiler how a "class" should be structured to be "compilable" in a given context.

Of course, it is theoretically possible to reiterate these steps over and over having

objects

types of objects (classes)

types of (types of objects) (concepts)

types of (types of (types of objects)) ( ??? )

.....

Right now, "concepts" have been dropped by the C++0x specifications (since they still require some work, and was retained was not the case to delay anymore)
The idea of conceptn I don't know -right now- if can be ever useful.


答:
In my understanding, Interfaces and Concepts have similar purposes in different parts of the C++ language.

As mentioned in the reply to the original question: The implementation of an Interface is decided by the implementor of a class at design time.  Once a class has been published it can support only those interfaces it was derived from at design time.

Two distinct Interfaces with exactly the same member functions and semantics (i.e. the same concept) will still be two distinct Interfaces.  If you wish to support the semantics of both Interfaces you may have to implement support twice.

That's the issue that Generic Programming intends to work around.  In C++ Generic Programming the type passed to a template simply needs to support the interface (non-capitalized, in the sense of the "programming interface" of a type) that is used by the template.  The two distinct Interfaces with the same member functions will match, and you will need to write the code only once.  In addition, any types (even without explicit Interfaces) that support the same interface will work with.

This leads to a second issue: what if you have two types with overlapping interfaces  but different semantics?  Generic programming will not be able to tell the difference and everything will compile just fine, but the run-time result will be suprising and probably wrong.

That's where Concepts come in.  If you grossly oversimplify you can consider a Concept the generic (template) version of an Interface. It needs to be implemented only once to apply to a large number of potential types that can "derive" from the Concept.  A Concept is a predetermined semantic interface of a (class-)type that is not limited to that type only. It is unlike an Interface in that two very different types (to the generic compiler) can still have the same Concept, without having to resort to limiting base-class Interfaces, or base-class Interfaces that have no actual compiler-visible semantics of their own but are only used for type distinction.

Title: Why were concepts (generic programming) conceived when we already had classes and interfaces?

Body:
Also on stackoverflow.com:

I understand that STL concepts had to exist, and that it would be silly to call them "classes" or "interfaces" when in fact they're only documented (human) concepts and couldn't be translated into C++ code at the time, but when given the opportunity to extend the language to accomodate concepts, why didn't they simply modify the capabilities of classes and/or introduced interfaces?

Isn't a concept very similar to an interface (100% abstract class with no data)? By looking at it, it seems to me interfaces only lack support for axioms, but maybe axioms could be introduced into C++'s interfaces (considering an hypothetical adoption of interfaces in C++ to take over concepts), couldn't them? I think even auto concepts could easily be added to such a C++ interface (auto interface LessThanComparable, anyone?).

Isn't a concept_map very similar to the Adapter pattern? If all the methods are inline, the adapter essentially doesn't exist beyond compile time; the compiler simply replaces calls to the interface with the inlined versions, calling the target object directly during runtime.

I've heard of something called Static Object-Oriented Programming, which essentially means effectively reusing the concepts of object-orientation in generic programming, thus permitting usage of most of OOP's power without incurring execution overhead. Why wasn't this idea further considered?

I hope this is clear enough. I can rewrite this if you think I was not; just let me know.


答: Create an account on bitbucket, fork the project, patch it, and send a pull request to the author when the bug is fixed?</p>

Title: Programmer Ethics: Can I fork a project from one code host to another?

Body:
Say I find this great snippet of code on Bitbucket. I really, really like it but there's a small bug I want to fix. On the other hand, I have all of my code on GitHub.

Is it ok to start a new repo on Github and refer to the original by a comment or on the wiki?


答:
Most changes happen incrementally, as a general rule.

A few things to keep in mind;

What is the history of the application?

Why is it ugly today?

What is the benefit of the architectural changes?

A good strategy is to work on the small things and ask a ton of questions about stuff (questions you can't learn from Google or the source, don't waste people's time). After you feel comfortable with the code base and the developers, you should have a good feel for why the code is the way it is. Sometimes, it's just, "Yeah, we had to hack something together and shove it out the door". If you can propose mild changes to small parts of the system that occur as you go along in your normal work, that will get more traction than radical rewrites.


答:
If the author is no longer maintaining the source, or will take too long to fix the issue then there's no problem. The whole (theoretical) point of the source being available is to be able to change it.

From a technical point of view moving from Bitbucket to Github isn't an issue as there's a fairly stable bridging tool between the two now. With Mercurial you easily shift between Codeplex, Bitbucket, Google Code and then push to Github via the bridge.

If it was my project I would be happy to see someone fork it, as so many open source projects are simply leeched with nothing given back. It would be polite to tell the author about the bug, and provide a patch for it.


答:
Short answer : You're mixing before-compile-time and compile-time concepts that have similarities in their purpose. Interfaces (abstract classes and all the object-orientation paradigm implementation) are inforced at compile-time. Concepts are the same idea but in the context of generic programming that in C++ occurs BEFORE compile time.
We don't have that last feature yet.

But let me explain from the beginning.

Long answer:

In fact, Concepts are just language inforcement and "made easier for the programmer" of something already present in the language, that you could call "duck typing".

When you pass a type to a template function, that is a generic function from which the compiler will generate real (inline) code when called, that type needs to have some properties (traits?) that will be used in the template code. So it's the idea of duck-typing BUT it's all generated and done at compile time.

What happens when the type don't have the required properties?

Well, the compiler will know that there is a problem only once the generated code from the template is compiled and fail. That means that the error that will be generated will be an error inside the template code, that will be shown to the programmer as his error. Also, the error will have tons of informations because of the meta informations provided in case of template code generation, to know which instantiation of the template we're talking about.

Several problems with that : first, most of the time, template code is library code and most programmers are users of library code, not writers of library code. That means that this kind of cryptic error is really hard to understand when you don't understand how the library is written (not just the design, how it is really implemented). The second problem is that even when the programmer did write the template code, the reasons of failure might still be obscure because the compiler will be able to tell that there is a problem too late : when the generated code is being compiled. If the problem is relative to the type properties, then it should check it even before generating the code.

That's what Concepts allow (and are designed for) : to allow the (generic code) programmer to specify the properties of types being passed as template parameters and then to allow the compiler to provide explicit errors in case the provided types don't fulfill the requirements.

Once the check is successful, the code will be generated from the template and then compiled, certainly successfully.

All the Concept checking occurs exclusively before compile-time. It checks types themselves, not object's types. There is no object before compile-time.

Now, about "interfaces".

When you create an abstract or virtual base type, you're allowing code using it to manipulate objects of the child types without knowing their real implementations. To enforce this, the base type expose members that are virtual and might be (or have to be) overloaded by the child types.

That means that the compiler can check at compile time that all objects passed to a function requiring a reference to the base class have to 1. be of one of the child types of the base class, 2. that child type have to have implementations of virtual pure functions declared in base classes if any.

So at compile-time, the compiler will check the interfaces of object's types and report if something is missing.

It's the same idea than Concepts, but it occurs too late, as said in the Concept description. It occurs at compile-time. We're not in generic code (template code), we're after it have been processed and it's already too late to check if the types fulfill generic requirements, that cannot be exposed by virtual base classes. In  fact, the whole object orientation paradigm implementation in C++ don't even exists when the template code is being processed. There is no objects (yet). That's

Classes describe constraints on objects to be used to check requirements for functions manipulating those objects.
Concepts describe constraints on types (including classes) to be used to check requirements for generic code to generate real code from those types and generic code combination.

So, again, it's the same "sanity check", but in another layer of the language, that is templates. Templates are a full (turing complete) language that allow meta-programming, programming types even before they appear in the compiled code. It's a bit like scripting the compiler. Let's say you can script it, classes are just values manipulated by the script. Currently, there is no way to check constraints on these values other than to crash the script in a non-obvious way. Concepts are just that : provide typing on these values (that in generated code are types). Not sure I'm clear...

Another really important difference between virtual base classes and Concepts is that the first one forces a strong relation between types, making them "bound by blood". While template metaprogramming allow "duck typing" that Concepts just allow to make requirements clearer.


问:
Easy to customize .NET CMS with ecommerce facility
I have tried DNN and nopCommerce. After going through their source-code, I realized they are not that easy to customize and need a fair amount of time to their documentation before any changes can be made. Also, they are pretty huge, as they cover up every single aspect of a CMS, from Page to Catalogue to Menu to SEO and so on.

My requirements are pretty simple; i just need the backend to add products and categories along with store handling functions. Other things like pages and menu's need not come under CMS.

So, Is there any simple .NET CMS that can help me speed up the development process, or should I develop my own or use one of the two mentioned above ??

答: You could always have a look at Umbraco - that's the only other .NET CMS with any market share & traction that I know of.  The biggest e-commerce CMS is Magento but that's written in PHP.</p>


问:
What is a good way to reset the Primary Key?
We've hit an application issue with an Oracle table Primary Key exceeding the limits used by a Java Integer (2 ^ 32) and one of the suggestions is to reset this to 1000 and let it start again.
OR change the code to use Java Long (2 ^ 64) instead.

This has a ripple effect since this key is used as ID by a lot of other systems as well. And there can be future duplication (in the far future)

Are there any suggestions on good and bad outcomes in this approach?

答:
Maybe I'm misunderstanding something. If you change the key to a long, why do you need to reset it to 1,000? Just keep going from 2^32 on.

Were these alternative solutions? Is this a class that holds objects that live for a very short time, so while it has very few rows at any particular time, it churns the primary key value rapidly?


答: You can maintain you fork wherever you want. But it is polite to pass bug fixes back to the original project, even if that means a little extra work on your part to jump through their project's hoops.</p>


问:
Applying SOLID principles
I am quite new to the S.O.L.I.D. design principles. I understand their cause and benefits, but yet i fail to apply them to a smaller project which I want to refactor as a practical exercise to use the SOLID principles. I know there is no need to change an application that works perfectly, but I want to refactor it anyway so I gain design experience for future projects.

The application has the following task (actually a lot more than that but let's keep it simple):
It has to read an XML file which contains Database Table/Column/View etc definitions and create an SQL file which can be used in order to create an ORACLE database schema.

(Note: Please refrain from discussing why I need it or why I don't use XSLT and so on, there are reasons, but they are off-topic.)

As a start, I chose to look only at Tables and Constraints. If you ignore columns, you could state it the following way:

A constraint is part of a table (or more precisely, part of a CREATE TABLE statement), and a constraint may also reference another table.

First, I will explain what the application looks like right now (not applying SOLID):

At the moment, the application has a "Table" class which contains a list of pointers to Constraints owned by the table, and a list of pointers to Constraints referencing this table. Whenever a connection gets established, the backwards connection will be established as well.
The table has a createStatement() method which in turn calls the createStatement() function of each Constraint. Said method will itself use the connections to the owner table and referenced table in order to retrieve their names.

Obviously, this doesn't apply to SOLID at all.
For example, there are circular dependencies, which bloated the code in terms of "add"/"remove" methods required and some large object destructors.

So there are a couple of questions:

Should I resolve the circular dependencies using Dependency Injection? If so, I suppose the Constraint should receive the owner (and optionally the referenced) table in its constructor. But how could I run over the list of constraints for a single table then?

If the Table class both stores the state of itself (e.g. table name, table comment etc) and the links to Constraints, are these one or two "responsibilities", thinking of the Single Responsibility Principle?

In case 2. is right, should I just create a new class in the logical business layer which manages the links? If so, 1. would obviously no longer be relevant.

Should the "createStatement" methods be part of the Table/Constraint classes or should I move them out as well? If so, where to? One Manager class per each data storage class (i.e. Table, Constraint, ...)? Or rather create a manager class per link (similar to 3.)?

Whenever I try to answer one of these questions I find myself running in circles somewhere.

The problem obviously gets a lot more complex if you include columns, indices and so on, but if you guys help me out with the simple Table/Constraint thing, I can maybe work out the rest on my own.

答:
Well, you should apply the S of SOLID in this case.

A table holds all constraints defined on it. A constraint holds all tables it references. Plain and simple model.

What you stick into that, is the ability to perform inverse lookups, i.e. to figure out by which constraints some table is referenced.

So what you actually want is an indexing service. That is a completely different task and should therefore be carried out by a different object.

To break it down to a very simplified version:

```<code>class Table {
      void addConstraint(Constraint constraint) { ... }
      bool removeConstraint(Constraint constraint) { ... }
      Iterator<Constraint> getConstraints() { ... }
}
class Constraint {
      //actually I am not so sure these two should be exposed directly at all
      void addReference(Table to) { ... }
      bool removeReference(Table to) { ... }
      Iterator<Table> getReferencedTables() { ... }
}
class Database {
      void addTable(Table table) { ... }
      bool removeTable(Table table) { ... }
      Iterator<Table> getTables() { ... }
}
class Index {
      Iterator<Constraint> getConstraintsReferencing(Table target) { ... }
}
</code>```

As for the implementation of the index, there's 3 ways to go:

the getContraintsReferencing method could really just crawl the whole Database for Table instances and crawl their Constraints to get the result. Depending on how costly this is and how often you need it, it may be an option.

it could also use a cache. If your database model can change once defined, you can maintain the cache by firing signals from the respective Table and Constraint instances, when they change. A slightly simpler solution would be to have the Index build up a "snapshot index" of the whole Database to work with, that you would then discard. That's of course only possible, if your application makes a big distinction between "modelling time" and "querying time". If it's rather likely to do those two at the same time, then this is not viable.

Another option would be to use AOP to intercept the whole creation calls and maintain the index accordingly.

Title: Applying SOLID principles

Body:
Well, you should apply the S of SOLID in this case.

A table holds all constraints defined on it. A constraint holds all tables it references. Plain and simple model.

What you stick into that, is the ability to perform inverse lookups, i.e. to figure out by which constraints some table is referenced.

So what you actually want is an indexing service. That is a completely different task and should therefore be carried out by a different object.

To break it down to a very simplified version:

class Table {
      void addConstraint(Constraint constraint) { ... }
      bool removeConstraint(Constraint constraint) { ... }
      Iterator<Constraint> getConstraints() { ... }
}
class Constraint {
      //actually I am not so sure these two should be exposed directly at all
      void addReference(Table to) { ... }
      bool removeReference(Table to) { ... }
      Iterator<Table> getReferencedTables() { ... }
}
class Database {
      void addTable(Table table) { ... }
      bool removeTable(Table table) { ... }
      Iterator<Table> getTables() { ... }
}
class Index {
      Iterator<Constraint> getConstraintsReferencing(Table target) { ... }
}

As for the implementation of the index, there's 3 ways to go:

the getContraintsReferencing method could really just crawl the whole Database for Table instances and crawl their Constraints to get the result. Depending on how costly this is and how often you need it, it may be an option.

it could also use a cache. If your database model can change once defined, you can maintain the cache by firing signals from the respective Table and Constraint instances, when they change. A slightly simpler solution would be to have the Index build up a "snapshot index" of the whole Database to work with, that you would then discard. That's of course only possible, if your application makes a big distinction between "modelling time" and "querying time". If it's rather likely to do those two at the same time, then this is not viable.

Another option would be to use AOP to intercept the whole creation calls and maintain the index accordingly.


答:
the answer is NO, but let's see why there is no CMS to support your unique requirement:

As the word CMS stands for Content Management System, therefore it should be able to support almost any type of content (commonly known as content-type). The most basic content types are text, images, videos, gallery, blog, etc. These content types are almost supported in all CMSs. Thus, an application that can only work for e-commerce, is technically, and safely can be put off the shelve of CMSs.

Usually, CMS software are here to speed your development. Imagine that you want to create 3-pages static site, (a common scenario for lots of personal websites). For such a site, the TCO (total cost of ownership) of adapting a CMS would be far more than simply creating static HTML pages. While this scenario was too simple, the point is, if your only need is eCommerce with categories and products, then talking from experience, I'm telling you that developing such a section from scratch would cost you less than implementing an eCommerce solution.

Even when I want to change part of my colleagues code, I need to get some help from him/her first. There is almost nothing on the web that you can work with without referring to it documents. Therefore, I think that you should change your mind about not reading the manual of a CMS.

Title: Easy to customize .NET CMS with ecommerce facility

Body:
I have tried DNN and nopCommerce. After going through their source-code, I realized they are not that easy to customize and need a fair amount of time to their documentation before any changes can be made. Also, they are pretty huge, as they cover up every single aspect of a CMS, from Page to Catalogue to Menu to SEO and so on.

My requirements are pretty simple; i just need the backend to add products and categories along with store handling functions. Other things like pages and menu's need not come under CMS.

So, Is there any simple .NET CMS that can help me speed up the development process, or should I develop my own or use one of the two mentioned above ??


问:
What's the difference between the terms "protocol" and "standard"?
I find the term "protocol" confusing (in the terms of computer science that is). If the protocol is just a set of rules, wouldn't it be easier if we used the term "standard" instead (like in "HTTP standard")?</p>

答:
A protocol is not a set of rules. A protocol is the thing those rules describe the rules of. This is why programs implement a protocol and comply with a standard.

Protocols are like languages. Standards are like dictionaries. For example, by analogy:

This answer = A web page

  English language =  the HTTP protocol

  Rules of English = the HTTP standard


答:
Not all protocols are standards (some are proprietary).
Not all standards are protocols (some govern other layers than communcation).</p>

Title: What's the difference between the terms "protocol" and "standard"?

Body: I find the term "protocol" confusing (in the terms of computer science that is). If the protocol is just a set of rules, wouldn't it be easier if we used the term "standard" instead (like in "HTTP standard")?</p>


答:
I think to answer this question, we can include other terms too, to make the concepts more clear:

Protocol: A set of rules for communication between computers (thus, you hear protocol usually in the field of network)

Standard: A level of quality; Thus, you can write code, which works, but is not a quality code or non-standard.

Convention: Just a kind of agreement, like telling somebody to put the images inside img folder. Not following conventions doesn't break the functionality, but is considered bad among the people who have agreed on that convention.

Specification: A detailed description, especially one providing information needed to make, build, or produce something.


答:
Definition of Protocol:

an original draft, minute, or record from which a document, especially
a treaty, is prepared.

Definition of standard:

something considered by an authority or by general consent as a basis
of comparison; an approved model.

Back to your question

If the protocol is just a set of rules, wouldn't it be easier if we
used the term "standard" instead (like in "HTTP standard")?

HTTP is both a protocol and a standard. It is, in fact, a standard protocol.

Quoted from wiki

The standards development of HTTP has been coordinated by the Internet
Engineering Task Force (IETF) and the World Wide Web Consortium (W3C),
culminating in the publication of a series of Requests for Comments
(RFCs), most notably RFC 2616 (June 1999), which defines HTTP/1.1, the
version of HTTP in common use.


答:
In my understanding, a protocol describes the communication between two points. One point creates some data that the other point must interpret. A protocol describes the data format, the states, requests and answers, and so on. E.g. a HTTP request from the client and the answer from the server.

For a specific problem, there are a gazillion possible protocols. Out of these, a standard chooses one specific protocol and makes it kind of mandatory. If all communication end points act accordingly to the standard, they can communicate with each other and understand each other.

This can happen officially or unofficially, because all communication partners just happen to use the same protocol which then became the standard protocol.


答:
In my experience, non-technical people often think it's OK to recycle "keys" or "IDs" after a certain amount of time because "we'll know by the date which one it was".  They don't understand the technical hurdles it can cause if you end up with a computer trying to figure out which one is which.

Having absolutely unique keys gives you some big advantages:

You can create a unique index to always be able to find it by the key

You can easily compare if two entities in memory are the "same" entity (just compare keys)

Error detection: if you have duplicate keys, that's an error.  Fail early.

If you're using sequential keys, it's automatically sorted by first created.

That's why I would favour moving to a 64 bit key rather than trying to recycle 32 bit keys.

Now, I can imagine a system where it might be OK to recycle keys.  If your data simply doesn't live long enough to ever have a duplicate key, then it might be alright.  Unfortunately that means you're designing yourself into a corner though.  What if someone wants to add an audit history later?  They probably want to store the audit history by key.

Title: What is a good way to reset the Primary Key?

Body:
We've hit an application issue with an Oracle table Primary Key exceeding the limits used by a Java Integer (2 ^ 32) and one of the suggestions is to reset this to 1000 and let it start again.
OR change the code to use Java Long (2 ^ 64) instead.

This has a ripple effect since this key is used as ID by a lot of other systems as well. And there can be future duplication (in the far future)

Are there any suggestions on good and bad outcomes in this approach?


答:
The simple answer to virtually all of your question is, "Because C++ compilers suck". Seriously. They're built on C's Translation Unit technology, which effectively bans many useful things, and the existing template implementations are hideously slow as they are. Concepts weren't cut for any conceptual reason- they were cut because there was no reliable implementation, ConceptGCC was extremely slow, and specifying concepts took an absurdly long time. Herb Sutter stated that it took more space to specify the concepts used in the Standard library than to specify the entire of templates.

Arguably, between SFINAE, decltype and static_assert, they're mostly implementable as it is now anyway.


问:
Should a primary key be immutable?
A recent question on stackoverflow provoked a discussion about the immutability of primary keys. I had thought that it was a kind of rule that primary keys should be immutable. If there is a chance that some day a primary key would be updated, I thought you should use a surrogate key. However it is not in the SQL standard and some RDBMS' "cascade update" feature allows a primary key to change.

So my question is: is it still a bad practice to have a primary key that may change ? What are the cons, if any, of having a mutable primary key ?

答: Yes, a primary key must be immutable, along with being non-null and unique.  However, I have yet to find a database that enforced the immutability of primary keys so you can probably go ahead and change their values if you really want to.</p>

Title: Should a primary key be immutable?


答: yes, it's ethical. That's why it's called "open source" (if not, then of course it would be illegal ...)</p>


答:
A computer protocol is a set of rules that determine the format and transfer of data.  The term protocol is used because it closely mirrors the rules of behaviour between individuals or nations.  The set of formal rules that are common in computer protocols are very similar to the rules of diplomacy (diplomatic protocol) or etiquette (personal protocol).  A standard is something different and not a rich a word to describe the interactions that are expressed within a protocol.  Also as noted by others a protocol may not need to be standard.

Finally, C3PO was a Protocol droid.  He could therefore mediate between both Astro Mech Droids, Moisture Vaporaters and Ewoks.  Calling him a Standard droid would not have so richly described his function.


问:
Examples and resources for writing a development proposal for a client
We're looking into our processes and client relationships at work and part of this is creating a standardised template for our development proposals that we send to clients.

The development areas we cover are mainly web development and design and mobile application development. On top of this we also offer native software developments for small to large companies.

What we are aiming for is a template for each development area, something we can base future proposals on.

How do you go about writing something like this? Are the resources to help on the internet?

More importantly maybe, what would you guys say is important to include in a proposal? This is normally pre-"indepth technical spec", but I would suggest (for instance) including a wireframe or mockup of the finished product. How detailed must you be in order to portray the project to the client and understand the needs of the project yourself in order to charge accordingly?

答:
How do you go about writing something like this? Are the resources to help on the internet?

Typically, the templates that I look at are the ReadySET templates.

I would start by looking at the Project Proposal, Project Plan, Resource Needs, Target Market and Benefits, and User Needstemplates to see the kind of information that is typically used during project inception. You'll probably get a good feel for the kind of information you need to capture early in a project from these templates.

A word of caution that I always provide when talking about templates - be sure to tailor them to the needs of your team, project, organization, and client.

More importantly maybe, what would you guys say is important to include in a proposal?

It depends on who is using the document and what the requirements say to produce. This typically needs to be addressed on a case-by-case basis. I'm a proponent of agile/lean documentation, especially principles such as traveling light (only producing what you need to produce to capture decisions and the current state of the system, and no more) and "just barely good enough" documentation.


问:
Is EF4 mature enough with MySQL or Oracle?
Is Entity Framework 4 with MySQL or Oracle mature enough to be used on production level web application?

Can it provide high level of performance, or should we stick with just plain data access with SqlCommand?

答:
no it isn't mature enough at all. When someone solves the problem with cross-apply queries being generated, then you can start thinking of checking whether performance issues were resolved too. (ie if EF generates a cross-apply type of query, it simply fails to run on Oracle or MySql, or any non-SqlServer DB for that matter).

Performance: EF4 is supposed to be better, but EF3 created truly awful sql for our legacy schema.

If you want to use an ORM there are others that do not have this limitation and some that perform better.


答:
A protocol defines a set of rules used by two or more parties to interact between themselves.

A standard is a formalized protocol accepted by most of the parties that implement it.


答: Fork it. It's open source and it's broke. Don't say you wrote it, just reference the original author.</p>


答:
Whatever happens, I hope you take the following message away.  As some of the responses above have pointed out sometimes a code re-write, for the best of technical reasons is sometimes infeasible for business/cost reasons.  Too many programmers live in the technical solution and refuse to consider that their, personal, quest for technical elegance/readability/best practice should be balanced by the business' needs to get things done.  In my personal experience the guy that does not strike that balance (from either direction) is often viewed as a liability within the team.

Don't stop questionning things though, even if you get some knockbacks, its the way we learn and grow.


问:
Why do programmers use or recommend Mac OS X?
I've worked on both Mac and Windows for awhile. However, I'm still having a hard time understanding why programmers enthusiastically choose Mac OS X over Windows and Linux?

I know that there are programmers who prefer Windows and Linux, but I'm asking the programmers who would just use Mac OS X and nothing else, because they think Mac OS X is the greatest fit for programmers.

Some might argue that Mac OS X got the beautiful UI and is nix based, but Linux can do that. Although Windows is not nix based, you can pretty much develop on any platform or language, except Cocoa/Objective-C.

Is it the applications that are only available on Mac OS X? Does that really make it worth it?

Is it to develop iPhone apps?

Is it because you need to upgrade Windows every 2 years (less backwards compatible)?

I understand why people, who are working in multimedia/entertainment industry, would use Mac OS X. However, I don't see what strong merits Mac OS X has over Windows. If you develop daily on Mac and prefer Mac over anything else, can you give me a merit that Mac has over Windows/Linux? Maybe something you can do on Mac that cannot be done in Windows/Linux with the same level of ease?

I'm not trying to do another Mac vs. Windows here. I tried to find things that can be done on Mac but not on Windows with the same level of ease, but I couldn't. So, I'm asking for some help.

答:
The fact is that it doesn't really matter.

If you really want to improve your productivity as a programmer, stop thinking about how cool is it to have the windows making all those fancy stuff and learn to use command-line tools, a great scripting language and a great editor.

You will see your productivity increase regardless of the OS you choose.

When you understand that those are the really useful tools you cannot live with, you'll forget about Mac OS fancy stuff and hype.


答:
IMO the role is one of guidance.  You've been around the block, so if another (not junior but not senior) developer has a question or runs into an issue in the Foobar module, you're the go-to guy to ask "I'm trying to do X with Foobar, any ideas?".  You should also be communicating the team's goals and effort to management while siding with the team on technical matters (e.g. if you and the team figure a project will take 4 months to do, don't cave in and tell the CEO it'll be done in 1 month, and then force everyone to work overtime).  You should also be responsible for making sure the code is of appropriate quality and the other team members are doing things right and not just hacking out garbage that's going to collapse down the road.

Of course that's all the theoretical.  It depends on the team; I've worked under "seniors" who knew nothing about any modern development in the past 5 years and were "Smithers" to senior management and would say "Sir, yes sir!" to any demand no matter how ridiculous, stifled creativity from other team members, and encouraged a very lackluster work environment instead of one of constant learning and craftsmanship.  I've also worked under very knowledgeable senior developers that took an active role making sure things were as best as they could be and never caved to management pressure.


答:
Other answers have spoken a lot about the politics of your situation, and I tend to agree. Unless you can present a compelling business case, a re-write is probably not on the cards.

However, that does not mean that you should forget the Boy Scout Rule:

Always leave the campground cleaner than you found it.

If while you are implementing something on this codebase, you can work out a way to clean up some aspect of the design or implementation, then that is something you should consider. You probably don't need to re-write the whole application to make better use of the MVC model, and if you are implementing some new business logic for a particular view, you could consider moving the logic out of the old view into the model and adding your new logic to that.


答:
Other people have covered the basic leadership aspect of this question, so I'll try to focus my points on the direct questions asked:

(a) What would one expect out of a senior / lead web developer of an
  organization (regardless of size)?

I would expect an individual with a strong character and technical knowledge-base. I would expect someone who will not just tear down ideas but propose new ideas to replace the ones they find to be deficient. I would expect someone who doesn't push or bully subordinate developers but tries to find ways that motivate, teach, guide each individual. I would expect someone willing to take responsibility and ownership of projects, concepts and decisions. "Yes-men" and "wall flowers" need not apply. A senior/lead needs to be able to deal with people just as effectively as (s)he does with code... possibly even better in some cases.

(b) Is there a difference between web development leader and senior
  web developer?

The primary difference I've observed is one of scope, and I've never seen it written down anywhere. A lead is typically responsible for the productivity of a single team. A senior may be responsible for several teams, a single team or no team. A lead is expected to help his subordinate developers achieve their goals within the scope of a specific project or assignment. By subordinate I simply mean developers who have been assigned to a project for which the lead is technically "in charge". I find often I am the lead on projects where several of the developers are either equal to or have more seniority than I do, so it's not a given that the lead will be the most "senior" member of the team. Given that scope, a senior developer is someone that entire organization can count on to have the necessary knowledge and experience to help anyone. A senior is expected to be a role model (as someone else said) to any developer in the organization and is also expected to assist junior developers with technical issues.

In short, for me: A lead helps. A senior teaches.


答:
Your have two primary roles as lead developer: to be an advocate for your team with the business side of your operation, and to provide technical guidance to your team.

As advocate, you should be helping to communicate requirements to your team, pushing back when the business side (be it management, project managers or sales people) makes unrealistic requests or demands, and generally dealing with anything that stops your team from writing code.

As technical mentor, you need to help your team make good decisions, assist them with any technical problems they have, and direct them to proper solutions.  You should be encouraging them to improve their skills, and be an absolute stickler for following proper development standards.

Most importantly, you need to be an impeccable role model.  Your code should be of the highest standard, your projects should be delivered on time and be of the highest quality.  What you do is going to be far more important than what you say.

EDIT: One further thing.  You need to be proactive with technical issues.  Do not wait for your team to come to you with problems.  Be aware of what they're working on, and go to them if they're taking too long, if you know they're on something tricky or outside their core skill set, or if they look frustrated.  Listen when people on your team start discussing technical problems without you, and step in if (and only if) you feel like they're starting to drift away from a decent solution, or if they're going in circles and not accomplishing anything.


答:
This is the pattern I believe to be proper:

Always start by introducing yourself, what your company does, and what you can do for your prospective client.

Define a problem, the customers' need to be satisfied.

Propose a solution.

Determine costs.

Define TERMS: payment, deliverables, what's included, what's not (support, etc...) and be clear about it.

Contact info.

A proposal needs to be generic, but addressed TO the client and make him feel as if the proposal is just for him. Not so different as in programming generics:

```<code>class Proposal<E>

private Proposal proposal<ClientX>
</code>```

(This part is my personal opinion, I know others would disagree) - Oh, and use a custom PDF with a nice background design (nice but elegant, serious). I have been on both the sending and receiving end of a proposal, and when you are a web company, involved in design, how you present yourselves in every aspect counts. A plain white PDF (Or worst, .doc or any other format) is not a good presentation.

Title: Examples and resources for writing a development proposal for a client

Body:
We're looking into our processes and client relationships at work and part of this is creating a standardised template for our development proposals that we send to clients.

The development areas we cover are mainly web development and design and mobile application development. On top of this we also offer native software developments for small to large companies.

What we are aiming for is a template for each development area, something we can base future proposals on.

How do you go about writing something like this? Are the resources to help on the internet?

More importantly maybe, what would you guys say is important to include in a proposal? This is normally pre-"indepth technical spec", but I would suggest (for instance) including a wireframe or mockup of the finished product. How detailed must you be in order to portray the project to the client and understand the needs of the project yourself in order to charge accordingly?

Body:
This is the pattern I believe to be proper:

Always start by introducing yourself, what your company does, and what you can do for your prospective client.

Define a problem, the customers' need to be satisfied.

Propose a solution.

Determine costs.

Define TERMS: payment, deliverables, what's included, what's not (support, etc...) and be clear about it.

Contact info.

A proposal needs to be generic, but addressed TO the client and make him feel as if the proposal is just for him. Not so different as in programming generics:

class Proposal<E>

private Proposal proposal<ClientX>

(This part is my personal opinion, I know others would disagree) - Oh, and use a custom PDF with a nice background design (nice but elegant, serious). I have been on both the sending and receiving end of a proposal, and when you are a web company, involved in design, how you present yourselves in every aspect counts. A plain white PDF (Or worst, .doc or any other format) is not a good presentation.


答:
Microsoft Commerce Server

It is very much .net based.  Very customizable on the front end but the Commerce server does handle the shopping cart and orders well.  It isnt cheap but it is less expensive than some of the other enterprise E-Commerce Solutions.  And it is supported by MS.  I know alot of people do not really like MS but if you are looking for a .net solution in ecommerce this is the MS Preferred solution.

The learning curve can be steep but you do not need to understand how to rewire the whole thing to get it going.  We were able to get it in and set up our first test site in 2 weeks.  We had production going in less than 3 months for one of our major customers which had alot of demands for customization.  We did this all with no prior experience with Commerce server.


答: I'm a senior devloper and I have several tech leads I work with. The difference is that they are the technical project managers. If there is a conflict between developers over a technicial issue, they make the decison as to what to do. If things are behind, they decide how to address that. They are responsible for making sure that people charge their time to project, that more hours are requested as needed, that new tasks are assigned, that code reviews are done (as senior I may do the code reviews), etc.  As a senior, I am generally assigned the more difficult tasks.   As a senior I am consulted and expected to mentor junior folks. Tech leads do all that too, but  they have the decision power and responsibility for the overall success of the project. As a senior, I'm only responsible for my own part of the project. </p>


答:
You may start from a different point of view to apply "Single Responsibility Principle" here. What you have shown to us is (more or less) only the data model of your application. SRP here means: make sure your data model is responsible only for keeping data - no less, no more.

So when you are going to read your XML file, create a data model from it and write SQL, what you should not do is implement anything into your Table class which is XML or SQL specific. Your want your data flow look like this:

```<code>[XML] -> ("Read XML") -> [Data model of DB definition] -> ("Write SQL") -> [SQL]
</code>```

So the only place where XML specific code should be placed is a class named, for instance, Read_XML. The only place for SQL specific code should be a class like Write_SQL. Of course, maybe you are going to split those 2 tasks into more sub-tasks (and split your classes into multiple manager classes), but your "data model" should not take any responsibility from that layer. So don't add a createStatement to any of your data model classes, since this gives your data model responsibility for the SQL.

I don't see any problem when you are describing that a Table is responsible for holding all it's parts, (name, columns, comments, constraints ...), that is the idea behind a data model.  But you described "Table" is also responsible for the memory management of some of its parts. That's a C++ specific issue, which you would not face so easily in languages like Java or C#. The C++ way of getting rid of those responsibility is using smart pointers, delegating ownership to a different layer (for example, the boost library or to your own "smart" pointer layer). But beware, your cyclic dependencies may "irritate" some smart pointer implementations.

Something more about SOLID: here is nice article

http://cre8ivethought.com/blog/2011/08/23/software-development-is-not-a-jenga-game

explaining SOLID by a small example. Let's try to apply that to your case:

you will need not only classes Read_XML and Write_SQL, but also a third class which manages the interaction of those 2 classes. Lets call it a ConversionManager.

Applying DI principle could mean here: ConversionManager should not create instances of  Read_XML and Write_SQL by itself. Instead, those objects can be injected through the constructor. And the constructor should have a signature like this

ConversionManager(IDataModelReader reader, IDataModelWriter writer)

where IDataModelReader is an interface from which Read_XML inherits, and IDataModelWriter the same for Write_SQL. This makes a ConversionManager open for extensions (you very easily provide different readers or writers) without having to change it - so we have an example for the Open/Closed principle. Think about it what you will have to change when you want to support another database vendor -ideally, you don't have to change anything in your datamodel, just provide another SQL-Writer instead.

Title: Applying SOLID principles

Body:
I am quite new to the S.O.L.I.D. design principles. I understand their cause and benefits, but yet i fail to apply them to a smaller project which I want to refactor as a practical exercise to use the SOLID principles. I know there is no need to change an application that works perfectly, but I want to refactor it anyway so I gain design experience for future projects.

The application has the following task (actually a lot more than that but let's keep it simple):
It has to read an XML file which contains Database Table/Column/View etc definitions and create an SQL file which can be used in order to create an ORACLE database schema.

(Note: Please refrain from discussing why I need it or why I don't use XSLT and so on, there are reasons, but they are off-topic.)

As a start, I chose to look only at Tables and Constraints. If you ignore columns, you could state it the following way:

A constraint is part of a table (or more precisely, part of a CREATE TABLE statement), and a constraint may also reference another table.

First, I will explain what the application looks like right now (not applying SOLID):

At the moment, the application has a "Table" class which contains a list of pointers to Constraints owned by the table, and a list of pointers to Constraints referencing this table. Whenever a connection gets established, the backwards connection will be established as well.
The table has a createStatement() method which in turn calls the createStatement() function of each Constraint. Said method will itself use the connections to the owner table and referenced table in order to retrieve their names.

Obviously, this doesn't apply to SOLID at all.
For example, there are circular dependencies, which bloated the code in terms of "add"/"remove" methods required and some large object destructors.

So there are a couple of questions:

Should I resolve the circular dependencies using Dependency Injection? If so, I suppose the Constraint should receive the owner (and optionally the referenced) table in its constructor. But how could I run over the list of constraints for a single table then?

If the Table class both stores the state of itself (e.g. table name, table comment etc) and the links to Constraints, are these one or two "responsibilities", thinking of the Single Responsibility Principle?

In case 2. is right, should I just create a new class in the logical business layer which manages the links? If so, 1. would obviously no longer be relevant.

Should the "createStatement" methods be part of the Table/Constraint classes or should I move them out as well? If so, where to? One Manager class per each data storage class (i.e. Table, Constraint, ...)? Or rather create a manager class per link (similar to 3.)?

Whenever I try to answer one of these questions I find myself running in circles somewhere.

The problem obviously gets a lot more complex if you include columns, indices and so on, but if you guys help me out with the simple Table/Constraint thing, I can maybe work out the rest on my own.

Body:
You may start from a different point of view to apply "Single Responsibility Principle" here. What you have shown to us is (more or less) only the data model of your application. SRP here means: make sure your data model is responsible only for keeping data - no less, no more.

So when you are going to read your XML file, create a data model from it and write SQL, what you should not do is implement anything into your Table class which is XML or SQL specific. Your want your data flow look like this:

[XML] -> ("Read XML") -> [Data model of DB definition] -> ("Write SQL") -> [SQL]

So the only place where XML specific code should be placed is a class named, for instance, Read_XML. The only place for SQL specific code should be a class like Write_SQL. Of course, maybe you are going to split those 2 tasks into more sub-tasks (and split your classes into multiple manager classes), but your "data model" should not take any responsibility from that layer. So don't add a createStatement to any of your data model classes, since this gives your data model responsibility for the SQL.

I don't see any problem when you are describing that a Table is responsible for holding all it's parts, (name, columns, comments, constraints ...), that is the idea behind a data model.  But you described "Table" is also responsible for the memory management of some of its parts. That's a C++ specific issue, which you would not face so easily in languages like Java or C#. The C++ way of getting rid of those responsibility is using smart pointers, delegating ownership to a different layer (for example, the boost library or to your own "smart" pointer layer). But beware, your cyclic dependencies may "irritate" some smart pointer implementations.

Something more about SOLID: here is nice article

http://cre8ivethought.com/blog/2011/08/23/software-development-is-not-a-jenga-game

explaining SOLID by a small example. Let's try to apply that to your case:

you will need not only classes Read_XML and Write_SQL, but also a third class which manages the interaction of those 2 classes. Lets call it a ConversionManager.

Applying DI principle could mean here: ConversionManager should not create instances of  Read_XML and Write_SQL by itself. Instead, those objects can be injected through the constructor. And the constructor should have a signature like this

ConversionManager(IDataModelReader reader, IDataModelWriter writer)

where IDataModelReader is an interface from which Read_XML inherits, and IDataModelWriter the same for Write_SQL. This makes a ConversionManager open for extensions (you very easily provide different readers or writers) without having to change it - so we have an example for the Open/Closed principle. Think about it what you will have to change when you want to support another database vendor -ideally, you don't have to change anything in your datamodel, just provide another SQL-Writer instead.


答:
Reuse is bad. Don't do it. It will cause more problems not solve them. For instance suppose you have a report that went out and someone questions the data a month later. If the record was removed and replaced by something else, you are then not going to understand what they are talking about. If you havea database that is missing some FK constraints (I know you shouldn't but in the real world it happens), you may suddenly have data attached to the wrong record in queries. This is especially true since you say this data ripples out to other systems and you may not know what affect it would have on them. It makes it almost 100% likely that you would have some very bad effects. For instance in doing imports, we determine whether to update or insert data based on the client's Id number. If you reuse that you may be overwriting information incorrectly in their systems (they may not be deleting old record but marking them as inactive).

Some systems allow you to use negative numbers as the key, you can double the available numbers by doing so. There is also the possibility of using GUID id. But I personally would go for moving to Long.

Whether you decide to reuse numbers or go to using Long, you need to notify the managers of every other system that might get data from you to let them know. They may need to make adjustments to their import or reporting processes or database structure. We had some horrible data integrity issues to solve as a result of a client changing their ids without telling us.


问:
What should I expect from a technical evaluation for C++?
I have been asked to go for a technical test/evaluation for a job as a junior developer, mainly using C++. This is my first test/evaluation, and it is 2 hours long.

My C++ is a bit rusty as I have been doing projects recently on PHP.

This is a UK company, however im guessing technical testing of candidates will be pretty much the same everywhere.

What should I expect in one of these tests?

答:
Well it depends on wether or not they'll let you use google. :P

I usually do pretty good in technical tests, so long as I can use the tools around me. When they want me to code blind its when I get in trouble. So the best advice I can give you is code blind at home... Make sure you remember trivial stuff we take for granted because we can check them easily if we don't remember.

Also, usually the check for especific skills they need, so if you know what you'll be working on, concentrate on that.

(This is in my general experience, I am not from the UK)


问:
What would truly happen if java.lang.String weren't final?
I'm a long time Java developer and finally, after majoring, I have time to study it decently in order to take the certification exam... One thing that has always bothered me is String being "final". I do understand it when a read about the security issues and related stuff... But, seriously, does anyone have a true example of that?

For instance, what would happen if String weren't final? Like it's not in Ruby. I haven't heard any complaints coming from the Ruby community... And I'm aware of the StringUtils and related classes that you have to either implement yourself or search over the web to just implement that behavior (4 lines of code) you're willing to.

答:
The main reason is speed: final classes can't be extended which allowed the JIT to do all kinds of optimizations when handling strings - there is never a need to check for overridden methods.

Another reason is thread safety: Immutables are always thread safe because a thread has to completely build them before they can be passed to someone else - and after building, they can't be changed anymore.

Also, the inventors of the Java runtime always wanted to err on the side of safety. Being able to extend String (something I often do in Groovy because it's so convenient) can open a whole can of worms if you don't know what you're doing.


答: If this is a pure C++ test (i.e. not a Windows/MFC/Managed C++ test), then spend a few hours or a day with Scott Meyer's Effective C++ and you should do very well.  It does not cover templates and the STL, but if they were interested in that, they probably wouldn't be giving you a two hour test.  It's been some years, but I used to interview C++ developers frequently.  Even though the ideas in Effective C++ are fundamental to C++ programming, only about ten percent of the candidates knew them.

Title: What should I expect from a technical evaluation for C++?

Body:
I have been asked to go for a technical test/evaluation for a job as a junior developer, mainly using C++. This is my first test/evaluation, and it is 2 hours long.

My C++ is a bit rusty as I have been doing projects recently on PHP.

This is a UK company, however im guessing technical testing of candidates will be pretty much the same everywhere.

What should I expect in one of these tests?


答:
It's C++, so you can expect anything, I mean REALLY anything.

Usually that involves trick questions, and some sort of polymorphism questions.

But could be something simple as well.

Be ready to answer a question on something like "why would you make a destructor virtual", what's "volatile", "design a class" for some unrealistic problem, "implement a linked list", "reverse a string", etc.


问:
What are the most relevant books on software task estimation for individuals?
What books have you read that helped you, as a programmer, learn to estimate time for completing small-to-medium programming tasks, such as bug fixes or implementing new features? Which have you the most helpful?

Please describe how it helped you, citing its strengths and weaknesses.

答:
I would suggest looking into the Personal Software Process. Watts Humphrey has three books that might be of interest - Introduction to the Personal Software Process, A Discipline for Software Engineering, and PSP: A Self-Improvement Process for Software Engineers.

Introduction to the Personal Software Process is probably where you want to begin. The PSP is a phased process, and it introduces the first phases of the process. I believe it introduces concepts through PSP 1.1, which are process discipline, measurement, estimation, and planning. This sounds very much like the topics that you are interested in. It's also a much easier read, focusing more on the practices and less on the statistical analysis that is part of full-blown PSP.

A Discipline for Software Engineering goes much deeper into these topics, and also includes the rest of the PSP (quality management, design) and begins to introduce the Team Software Process for larger projects. PSP: A Self-Improvement Process for Software Engineers is extremely in-depth and also covers the entire PSP. The difference is in the focus. A Discipline for Software Engineering is designed for a graduate course and discusses some of the research and topics of academic interest, while PSP: A Self-Improvement Process for Software Engineers is written for people working in industry and improving the process of software developers, omitting topics that are purely academic in nature.

I should add a warning that "out of the box" PSP is very heavy and script/form driven. However, it doesn't need to necessarily be that way - it's a framework that can be tailored. Also, many of the PSP practices can be integrated with an existing process without a significant amount of overhead.


答:
Here is a good site I have referenced before:

http://jamesshore.com/Agile-Book/estimating.html

We do use Agile development however.

It helped me by getting down to realistic estimations, and being able to more clearly explain and back those estimations.

Title: What are the most relevant books on software task estimation for individuals?

Body:
What books have you read that helped you, as a programmer, learn to estimate time for completing small-to-medium programming tasks, such as bug fixes or implementing new features? Which have you the most helpful?

Please describe how it helped you, citing its strengths and weaknesses.


答:
It isn't a book, but ...

The founder of Stack Overflow and Stack Exchange created a reasonable estimating and scheduling methodology that he called "Evidence-based scheduling". The methodology was implemented in the FogBugz bug tracking and development management system.

Short summary:

** break features/tasks into small chunks, no bigger than 16 hours each.

** have the programmers make estimates of the time.

** keep track of the actual time spent.

** Use estimate v. actual history to predict actual from estimates and build a schedule.

Note: the very first bit of Joel's writing I read was his "Painless Software Scheduling" article. Joel has since deprecated it in favor of EBS, but it may have some value as a starting point while you build history or if you are working alone.


答:
Make a short list of what you think should be included. You can look for examples that have the most over-lap. Google Docs has several templates.

Revisit your previous proposals and do a little debriefing on how they were accepted by the clients. Other than just being inconsistent, there may be other problems expecially if clients are asking you to redo for the same reason.

Don't have a template that tries to include everything without the ability to remove unecessary items. No one want to read through a page of items with "NA". Avoid the tempation to take a previous proposal for a similar client and edit it for a new one. It's like copy and pasting large blocks of code.

Ask the client what format they prefer, but give a list of options. You never know what's required by your end users. You don't want them doing a presentation of your proposal after it has been printed and scanned int PowerPoint. Spreadsheets are nice if they want to do a little math. You never know; they may actually want to add something to the project.


答: A console program tends to be refined over time while a GUI program tends to be screwed.</p>

Title: What are the major differences when moving from console-based to GUI-based programming?

Body:
I started, like many others, with console-based (as in terminal, not Playstation) programming. But sooner or later, one needs to touch upon GUI-based programming, whether you want to or not. This transition holds many changes in how you need to think about the frontend (and possibly also the backend).

So, what are the major differences when moving from console-based programming to GUI-based programming?


问:
suggesting large changes/a rewrite as an intern
The context:

it's an internal project (that I don't think a lot of people use)

it's old

we're updating it

The issues:

it abuses the mvc framework (no use of models, business logic in views, etc)

what we're being asked to do is small, but because of the low cohesion we have two options:

continue to botch things

move large chunks of code around or rewrite the thing

The solutions (I see):

continue working with it, ignore best practices in favor of being done soon and not introducing new bugs by refactoring/rewriting

refactor/rewrite

I guess my question is really: if I want to make large changes to this project, how do I do propose that without insulting anyone? Or would it be better for me to simply go with the flow even if that means (metaphorical) duct-tape sometimes?

答:
There's no hurt in suggesting a rewrite if you ask nicely and make a logical case (not just a hunch or its the better way to do it).  There's a high chance that rewriting a low-use application will be shot down, and there's a good chance that whoever originally wrote the system is still around (and higher in the hierarchy than you) and may not take kindly to criticism.

So don't say "We need to rewrite this horribly designed system that violates basic MVC principles", ask it as an open question to the appropriate higher-ups (people directly above you).  Something like "I'm wondering if rewriting the system in the MVC model might save a lot of time in the long run.  What do you think?  I bet we could halve the maintenance time with a major rewrite (in say 2 weeks) that incorporates MVC model, TDD, etc. was done and that after two months of routine maintenance we'll break even".  The response may be, no we don't think that's called for -- I disagree with your time estimates and the likelihood the new system will be a suitable replacement.  Or the response could be, fine go for it, but remember if your new system doesn't work as good/better than the new system in the time frame you proposed that people will blame you.  And even if the system is little used; it may not be acceptable to stop updating it with minor fixes during the rewrite period.


问:
Switching to Windows Identity Foundation - Should we use the SQL Server role and membership provider?
We have an application which uses SQL Server as the back end.  It was client server based, now it will be web based.  Our implementation to logon was a user ID and password hash/salt stored in the database.   Additionally, all policies and roles were stored in our table schema and assigned to users and or user defined groups.  So, they would login, authenticate, and then we would pull the role(s) and policies for that user so they could use the parts of the application that thier role(s) and policies allowed for.

We are investigating WIF now that it is web based.

Ideally we would like to re-use our current model, that is, be able to logon using our existing table(s) and then pull the roles and polices afterward.

However, there is a SQL Server role and membership provider.

Would it be easier to switch the login, roles, and membership using the built in SQL Server provider and deprecate our table schema?  Or should we build a provider from scratch?

答: As you haven't had any answers in 3 weeks, I'll offer my thoughts.  Is there a business case for making this change?  Presumably the existing security setup works and is well understood and therefore I would only look to change it if I could demonstrate a reason for doing so.</p>


问:
What is the senior web developer's role in the team?
With a team of 3 other web developers i have the title as lead web developer for a year now. This is my first job as a lead.

I'm pretty set on what my roles are from management. I'm curious what other senior level developers do. I primarily curious as to what others people responsibilities are as the lead/senior developer in other organizations; as I've only encountered working in a small/medium company.

(a) What would one expect out of a senior / lead web developer of an organization (regardless of size)?

(b) Is there a difference between web development leader and senior web developer?

I reviewed some threads and there was just one that discussed when you should call yourself a senior developer but doesn't comprehensively discuss the roles of what a senior developer should do with his/her team.

答:
Senior web developers can be viewed as the person that can take a problem, find various solutions and implement the best on their own.  The one person army in a sense.  Mentor junior developers to help improve the overall team performance.  Could also be brought in to harness expertise in various software packages as the senior may be expected to really know something better than other developers in some cases.  Generally the skills the developer has get used for the maximum benefit which can be a combination of mentoring, consulting, coding, designing and creating processes.

Lead web developers can come in a couple of different forms to my mind.  The lead for a team is the administrative head and is who would do an overall performance review, be aware of which projects a developer is allocated and handle some paperwork while also being a developer once that is done.  There is also the lead for a project which is where the person's focus is much more narrow as it is just for this project that this person has the responsibility of enforcing standards and practices within the team.  Thus there is the question what is the lead really leading?  A project or a group of developers from an administrative perspective?


问:
Are there revision repositories which implement commenting on revisions other than a fixed single commit message?
Sangdol asked: Why can’t I edit and SVN commit message? There are good reasons to maintain individual records ‘as is’ for historical purposes. However, there is an arguably objective hazard in not limiting the spread and use of misleading, and dangerous data.

Aside: Certainly, sometimes, one should just suck up they’ve made an error.

That aside, er aside, it appears clearly beneficial to have some mechanism for recording and sharing the best possible information. It also seems clearly beneficial to have some mechanism for correcting ‘bad data’ and informing others of ‘hazardous data’.

In the Sangdol thread l0b0, comments:

You're right. There is a fundamentally flawed design assumption in all
  VCSes I've ever seen: A commit has one commit message, which is
  immutable. As Alex says, we should "allow multiple versions of the
  commit message".

To keep the question less subjective, your answers should be an objectively better practice than the ‘Moses Principle’ of, “Get it right first time, we’re carving this puppy in stone”, and address the ability to handle one or more problems along the lines of (I’m willing to update and alter this list if there are better suggestions):

Suppose I discover that a commit message I entered a month ago is misleading, confusing, and downright wrong. Shouldn't I be able to added a correcting notation that will be seen by everyone who sees the incorrect message? (I agree the original message should be easily available unmodified and the change itself should be tracked and timestamped. But I disagree that this constitutes "changing history".) – David Schwartz comment from the Sangdol question.

答:
It can definitely be done. You can link each revision with data in a ticket system for example. The Trac tracking system offers TracLinks. You can link from a commit message to more detailed information. Jira also supports linking commits to issues, Redmine does, too.

I am not sure about Microsoft's TFS system, but I am pretty sure its project management plugins/templates let you link to revisions of its source control, too.

While you probably cannot alter the original message without admin privileges, you can prepare reports in these systems to find additional comments linked to certain revisions.

Also, I think that a tracking system is the better place to keep such information. It's easier to manage and has various features like linking to requirements and documents, too. ...thinking of the single responsibility principle...


问:
Is it better to develop apps using a platform specific technology or web technologies?
I happened to read an interesting article the other day that talked about building mobile applications using Javascript and HTML5. One interesting point they brought out was how this approach worked across multiple platforms, different hardware (ex. screen size) and software (ex. iPhone, WP7, Mac, Windows).

I also noticed something interesting posted on Microsoft's Build Website for their upcoming conference. They seem to put a lot of emphasis on HTML5 and JavaScript. It does seem ideal to develop a single application (of course it would still require minor modifications) and have it work on tablets, PCs, mobile devices, TVs or pretty much any internet-capable device.

Is this a shifting trend?

Obviously it's no fun learning a technology just to find out a year later that it's getting shut down. In my opinion it seems rather difficult as it stands to do certain functionality like animations or data-binding (my favorite!) with HTML5 and JavaScript when compared to Silverlight. In this case the tools alone make it a better choice (Expression Blend and Visual Studio 2010). I am concerned though because it has been getting easier to do things on the web that just a few years ago didn't seem possible.

Is there still a place for technologies like Flash and Silverlight when it comes to developing applications or should we be aiming to gear our apps toward web-specific technologies such as HTML5, CSS3, and JavaScript?

答:
The big shift toward HTML5/JS came recently with the introduction of hardware acceleration in IE9 and now other browsers.  Before, you just couldn't get the performance out of HTML that you could with Silverlight and Flash.  They had access to hardware and HTML didn't.

The vast majority of mobile browsers support HTML5, and so do their webviews in apps that things like Phonegap takes advantage of.  So in the mobile space, depending upon exactly how much hardware you want to use, HTML5/CSS3/JS is a prerfectly good option.

With Windows 8, there's going to be HTML5 apps in the new tablet view, but native apps are still very much the core part of the experience (Visual Studio won't be HTML5 for example...I don't think).  However, since the markup/JS is hardware accelerated it can now be every bit as fast as a native application.

To your point about if Flash and Silverlight have a place - Windows Phone 7's UI is based on Silverlight, so I'm sure it'll be around for a while.  Also, these technologies are still the only way to get a rich web media experience on older browsers like IE7, which are still very much alive in the XP world.  Until every user you want to view something is off of that, you'll need a fallback method.  Flash is still great for that with video and graphics.