问:
Database Change Auditing - Part of or Abstracted from ORM / Application Layer?
My fellow developers and I are at a crossroads in how to go about continuing our auditing of database changes.

Most of our applications log changes via INSERT, UPDATE, and DELETE triggers.

A few of our newer applications audit at the ORM layer; specifically using Hibernate Envers.

While ORM layer auditing provides a much cleaner interface and is much more maintainable, it will not capture any manual database changes that are made.  ORM layer auditing also means that our libraries will currently require a dependency on our ORM implementation unless, specifically in our case for example, JPA plans on providing something in the near future.

Is there a common paradigm that addresses this?

答:
ORM layer auditing also means that our libraries will currently require a dependency on our ORM implementation unless

That's Right. you want all your business logic in one place, including logging.

it will not capture any manual database changes that are made

Unless you manually log the Changes ... If you are ok with making data entries manually (bypassing your business layer) I see no reason why making manual Log entries would bother you.

Lastly, there is the option to duplicate logic in the Trigger. Have a field that captures the Source of the Data, so you will know what entries where made manually (and by whom) an which was by the app. (This is a good idea regardless of your logging problem). So you can code the trigger to fire only for Manual updates. (This is a Horrid Solution... But it is viable)


问:
What should my "large codebase sample" look like?
If an employer asks for a large code sample, one for an entire project, what characteristics should the project have to show architectural skills and the ability to manage a large codebase?

For example, should I show off managing modules/dependencies? writing test/build scripts?  design patterns? etc.

答:
Your sample codebase can only show what you are knowledgeable about. For example, if you know how to write tests, then it can (and should) include tests.

Some good design principles can include:

Single Responsibility

High Cohesion

Don't Repeat Yourself (DRY)

Keep It Simple Stupid (KISS)

Separation of Concerns (SoC)

Your codebase should also have well-named language elements (classes, functions, etc.), be well-documented and use a consistent coding style to make it easier to read.

ContentLicense: CC BY-SA 3.0


问:
How long to spend estimating programming tasks?
For example, if I break a project into n discrete work products (say classes or functions or components) is there a time t such that n*t is a suitable amount of time to spend on estimation?</p>

答:
If you have enough information to have broken it down to that level, you shouldn't spend more than a minute on each one. You're not going to be correct anyway, but you're going to be as correct after a minute as after an hour.

If, on the other hand, you were talking about user stories, I would suggest getting the stakeholders in a room and spending five minutes asking questions before estimating.

Regardless, don't waste much time doing estimates. They're not useful or accurate enough to be worth the effort.


答:
It's not the size of the code base so much as the scope and complexity of the problem that was addressed and solved. Compare:

A website with one product for sale and paid for through PayPal.

A commercial site that displays thousands of products in hundreds of categories, indicating realtime quantity-in-stock, expected shipping time and taxes for international customers, connected to the main production systems so that the warehouse pick-pack-ship process is triggered automatically, invoices (with appropriate discounts) are generate as product is shipped, etc., etc.

Yes, the second system will be larger, but it's the complexity of getting all of these systems humming the same tune that makes this an architectural challenge. (Especially when half the systems are legacy and if you touch them/screw them up you die.)

So I would say this: give the person interviewing you the Big Picture® (either verbally or in an Executive Summary type document), and then offer to go into any level of detail they desire of any of the workflows or subsystems.

Title: What should my "large codebase sample" look like?

Body:
If an employer asks for a large code sample, one for an entire project, what characteristics should the project have to show architectural skills and the ability to manage a large codebase?

For example, should I show off managing modules/dependencies? writing test/build scripts?  design patterns? etc.


问:
PHP Riak in place update
From what I can see, when using Riak to update an object, I first need to load the object into PHP, then edit the object, then store the object back to the Riak database.

I was wondering if there is a way to update a bucket without pulling it into PHP first. That way, it would save on the network I/O and latency of pulling it into the PHP script.

Can objects be edited directly on the Riak side of things?

Edit:

Is there away to push data to the end of a raik object, so if i have an object that is numeric array can i make a push to add subject that i know its not there or no in place updates what so ever

答:
No.

Riak has no ability to modify an object in place. The method you describe (read/modify/write) is how you modify an object in Riak.

Title: PHP Riak in place update


答:
I think it depends on what you need. If, for example, the resources allocation of your project depend on it (as was the case around here sometimes), it is better to do it carefully. In the other way if you are doing a project that does not have this kind of necessity you may not go into too much detail. Spending too much time on it is not a good idea cause to do an accurate estimation is very hard.

There is a famous concept called Cone of Uncertainty and Cone of Uncertainty at Wikipedia that says how much accurate an estimation usually can be. It is worth reading about.

Title: How long to spend estimating programming tasks?

Body: For example, if I break a project into n discrete work products (say classes or functions or components) is there a time t such that n*t is a suitable amount of time to spend on estimation?</p>


问:
Two interfaces with identical signatures
I am attempting to model a card game where cards have two important sets of features:

The first is an effect. These are the changes to the game state that happen when you play the card. The interface for effect is as follows:

```<code>boolean isPlayable(Player p, GameState gs);
void play(Player p, GameState gs);
</code>```

And you could consider the card to be playable if and only if you can meet its cost and all its effects are playable. Like so:

```<code>// in Card class
boolean isPlayable(Player p, GameState gs) {
    if(p.resource < this.cost) return false;
    for(Effect e : this.effects) {
        if(!e.isPlayable(p,gs)) return false;
    }
    return true;
}
</code>```

Okay, so far, pretty simple.

The other set of features on the card are abilities. These abilities are changes to the game state that you can activate at-will. When coming up with the interface for these, I realized they needed a method for determining whether they can be activated or not, and a method for implementing the activation. It ends up being

```<code>boolean isActivatable(Player p, GameState gs);
void activate(Player p, GameState gs);
</code>```

And I realize that with the exception of calling it "activate" instead of "play", Ability and Effect have the exact same signature.

Is it a bad thing to have multiple interfaces with an identical signature? Should I simply use one, and have two sets of the same interface? As so:

```<code>Set<Effect> effects;
Set<Effect> abilities;
</code>```

If so, what refactoring steps should I take down the road if they become non-identical (as more features are released), particularly if they're divergent (i.e. they both gain something the other shouldn't, as opposed to only one gaining and the other being a complete subset)? I'm particularly concerned that combining them will be non-sustainable as soon as something changes.

The fine print:

I recognize this question is spawned by game development, but I feel it's the sort of problem that could just as easily creep up in non-game development, particularly when trying to accommodate the business models of multiple clients in one application as happens with just about every project I've ever done with more than one business influence... Also, the snippets used are Java snippets, but this could just as easily apply to a multitude of object oriented languages.

答:
From Wikipedia: "interface is often used to define an abstract type that contains no data, but exposes behaviors defined as methods". In my opinion an interface is used to describe a behavior, so if you have different behaviors it makes sense to have different interfaces. Reading your question the impression that I got is that you are talking about different behaviors so different interfaces may be the best approach.

Another point that yourself said is that if one of those behaviors change. Then what happens when you have just one interface?


答:
Just because two interfaces have the same contract, doesn't mean that they're the same interface.

Liskov Substitution Principle states:

Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.

Or, in other words: Anything that is true of an interface or supertype should be true of all its subtypes.

If I'm understanding your description properly, an ability is not an effect and an effect is not an ability. Should either one change its contract, it's unlikely the other one will change with it. I can see no good reason to try to bind them to each other.

Title: Two interfaces with identical signatures

Body:
I am attempting to model a card game where cards have two important sets of features:

The first is an effect. These are the changes to the game state that happen when you play the card. The interface for effect is as follows:

```<code>boolean isPlayable(Player p, GameState gs);
void play(Player p, GameState gs);
</code>```

And you could consider the card to be playable if and only if you can meet its cost and all its effects are playable. Like so:

```<code>// in Card class
boolean isPlayable(Player p, GameState gs) {
    if(p.resource < this.cost) return false;
    for(Effect e : this.effects) {
        if(!e.isPlayable(p,gs)) return false;
    }
    return true;
}
</code>```

Okay, so far, pretty simple.

The other set of features on the card are abilities. These abilities are changes to the game state that you can activate at-will. When coming up with the interface for these, I realized they needed a method for determining whether they can be activated or not, and a method for implementing the activation. It ends up being

```<code>boolean isActivatable(Player p, GameState gs);
void activate(Player p, GameState gs);
</code>```

And I realize that with the exception of calling it "activate" instead of "play", Ability and Effect have the exact same signature.

Is it a bad thing to have multiple interfaces with an identical signature? Should I simply use one, and have two sets of the same interface? As so:

```<code>Set<Effect> effects;
Set<Effect> abilities;
</code>```

If so, what refactoring steps should I take down the road if they become non-identical (as more features are released), particularly if they're divergent (i.e. they both gain something the other shouldn't, as opposed to only one gaining and the other being a complete subset)? I'm particularly concerned that combining them will be non-sustainable as soon as something changes.

The fine print:

I recognize this question is spawned by game development, but I feel it's the sort of problem that could just as easily creep up in non-game development, particularly when trying to accommodate the business models of multiple clients in one application as happens with just about every project I've ever done with more than one business influence... Also, the snippets used are Java snippets, but this could just as easily apply to a multitude of object oriented languages.


问:
How is it possible to write the compiler of a programming language with that language itself

Possible Duplicate:

  How could the first C++ compiler be written in C++?

You probably heard that Microsoft released a new language called TypeScript which is a the typed superset of JavaScript.

The most interesting thing that makes me wonder is the fact that its compiler writen in TypeScript itself.

Call me ignorant but I really couldn't figure out in my head how that is possible. This is just like chicken and egg problem in my head because there is no compiler to compile TypeScript's compiler in the first place. How is it possible to write a compiler of the compiler of a programming language with that language?

答: A slight variation is where the language itself is interpreted, so the compiler is written in the language itself, runs in the interpreter and compiles itself.   These languages (classically, Lisp) have very different runtime representations for compiled and interpreted code, but the compiled form is required to preserve the same semantics.</p>


问:
Is it better to define all routes in the Global.asax than to define separately in the areas?
I am working on a MVC 4 project that will serve as an API layer of a larger application.

The developers that came before me set up separate Areas to separate different API requests (i.e Search, Customers, Products, and so forth).

I am noticing that each Area has separate Area registration classes that define routes for that area.  However, the routes defined are not area-specific (i.e. {controller}/{action}/{id} might be defined redundantly in a couple of areas).

My instinct would be to move all of these route definitions to a common place like the Global.asax to avoid redundancy and collisions, but I am not sure if I am correct about that.

答:
Your route organization will depend entirely on what your goals are.

Some routes are organized in such a way that the resulting URLs increase search engine optimization.  Others are designed for readability, or to be as short as possible.  Still others are arranged hierarchically, based on the folder structure of the application.

In short, there is no "one, true way."  This is why routing exists in the first place.  Were there only a single right way to arrange your URLs, you wouldn't need the "patch-bay" mechanism that routing provides.

If your question is where to put the routes, you should put them where it makes most sense to you.  If the areas function independently and have different routing rules, it probably makes sense for each area to have its own routes.  If, on the other hand, all the areas use the same routing scheme, it probably makes sense to keep a set of global rules.

It is my understanding that ASP.NET MVC checks the area routing rules first, so if you have some rules that are specific to a certain area, you can put those rules in the area, and if none of them match, the routing engine will fall back to the global routes.


问:
What can procs and lambdas do that functions can't in ruby
I've been working in Ruby for the last couple weeks, and I've come to the subject of procs, lambdas and blocks.  After reading a fair share of examples from a variety of sources, I don't how they're much different from small, specialized functions.  It's entirely possible that the examples I've read aren't showing the power behind procs and lambdas.

```<code>def zero_function(x)
    x = x.to_s
   if x.length == 1
    return x = "0" + x
   else
    return x
   end
end

zero_lambda = lambda {|x|
  x = x.to_s
   if x.length == 1
    return x = "0" + x
   else
    return x
   end
}

zero_proc = Proc.new {|x|
  x = x.to_s
   if x.length == 1
    puts x = "0" + x
   else
    puts x
   end
}

puts zero_function(4)
puts zero_lambda.call(3)
zero_proc.call(2)
</code>```

This function, proc, and lambda do the exact same thing, just slightly different.  Is there any reason to choose one over another?

答:
Good question! I'm curious on the answers.

One difference I know:

You get no error with this call:

```<code>zero_proc.call()
</code>```

But you get a wrong number of arguments (0 for 1) (ArgumentError)-error with the following calls:

```<code>puts zero_function()
puts zero_lambda.call()
</code>```

Methods and lambdas check the number of parameters, Proc-objects don't, the use nil if there are missing parameters.

Body:
Good question! I'm curious on the answers.

One difference I know:

You get no error with this call:

zero_proc.call()

But you get a wrong number of arguments (0 for 1) (ArgumentError)-error with the following calls:

puts zero_function()
puts zero_lambda.call()

Methods and lambdas check the number of parameters, Proc-objects don't, the use nil if there are missing parameters.


答:
Short Answer: Moving area route registrations to common place is not necessary, better to keep them under specific Areas that they belong to. You may use      AreaRegistration.RegisterAllAreas(); statement in Global.asax that does the registration.

I have listed and example code (for Clients area) that you may need to declare for each area in your project.

```<code>    public class ClientsAreaRegistration : AreaRegistration
        {
            public override string AreaName
            {
                get
                {
                    return "Clients";
                }
            }

     public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Clients_default",
                "Clients/{controller}/{action}/{*id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
}
</code>```

Title: Is it better to define all routes in the Global.asax than to define separately in the areas?

Body:
I am working on a MVC 4 project that will serve as an API layer of a larger application.

The developers that came before me set up separate Areas to separate different API requests (i.e Search, Customers, Products, and so forth).

I am noticing that each Area has separate Area registration classes that define routes for that area.  However, the routes defined are not area-specific (i.e. {controller}/{action}/{id} might be defined redundantly in a couple of areas).

My instinct would be to move all of these route definitions to a common place like the Global.asax to avoid redundancy and collisions, but I am not sure if I am correct about that.

Body:
Short Answer: Moving area route registrations to common place is not necessary, better to keep them under specific Areas that they belong to. You may use      AreaRegistration.RegisterAllAreas(); statement in Global.asax that does the registration.

I have listed and example code (for Clients area) that you may need to declare for each area in your project.

    public class ClientsAreaRegistration : AreaRegistration
        {
            public override string AreaName
            {
                get
                {
                    return "Clients";
                }
            }

     public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Clients_default",
                "Clients/{controller}/{action}/{*id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
}


答:
Good estimates are the once that are based on facts not assumptions.

Thus, if you already had a similar project(s) and captured your previous estimation time, that might server as a good estimation base to start. However, depending on your project scope there might be unknown artifacts, which is better to clarify with BA or product owner asap.

It is also true to say that : Software Project Estimation is Inherently Inaccurate.
However, there are some realistic estimation practices that might help:

People who do the work, should participate in the project estimation

Bring in the experts: Expert judgment is critical to project success

Estimate large pieces as a range

Use the Delphi Technique:  This is a method that helps converge opinions of the team should there be a conflict in software project estimation.

Keep in mind the cost

Keep in mind the allocated resources available to perform the work


答:
Actually you need estimation to help other stakeholders assign relative priority - so broad-based estimates that at least say task1 is roughly 3 times effort compared to task2, (even if in terms of hours its not very accurate in the end) are useful. Spend as much time is needed to understand what those tasks are (for achieving certain goals) and then having rough estimates for them. </p>

<p>Once you have relative priority, just focus on doing things and adjust estimates en-route. In other words, spend little time in up-front estimates, but do refine your estimates as time goes so that the project plan gives a good idea when what is going to get done. </p>

Body:
Actually you need estimation to help other stakeholders assign relative priority - so broad-based estimates that at least say task1 is roughly 3 times effort compared to task2, (even if in terms of hours its not very accurate in the end) are useful. Spend as much time is needed to understand what those tasks are (for achieving certain goals) and then having rough estimates for them.

Once you have relative priority, just focus on doing things and adjust estimates en-route. In other words, spend little time in up-front estimates, but do refine your estimates as time goes so that the project plan gives a good idea when what is going to get done.


问:
Are corner and edge cases too often ignored or disregarded and why?
I have the feeling that a lot of developers disregard corner and edge cases. Often they tend to just ignore these.

I was once working on a logistics project. In the order management of the application there was a case where about 5-10% of the orders had to be specially handled. One colleague said that we just shouldn't handle that case automatically, which would have lead to a high manual workload of the applications users. I think this has somewhat to do with a bad attitude.

Another example I noticed shortly was in a comment to one of my answers here. Since this was just a comment, I think the reason for that was just, that the commentator did not pay too much attention for it.

Have you made similar experiences? Is this something you see very often? Is this just a matter of attitude or are there other reasons?

答:
The cost is one of the reasons.

When you're implementing a feature which is used by half of your 1 000 000 users, it means that the cost of the feature is divided by 500 000. Even if implementing it is terribly expensive, it doesn't matter. If this feature costs you $100 000, each user will pay ten cents, given that only half of the users will pay for the feature they don't use.

When, on the other hand, a feature is used only by a few of your users, not only it doesn't worth to implement it, but often, you will even stop supporting an existent one and remove it from the product. This is what happens often in Microsoft products: when you read that a feature, used by thousands of users, was discontinued in the next version of Windows, it is easy to understand: maintaining a codebase used by only a few thousands of users is too expensive for a product with so many customers.

The same applies to bugs. If 1% of your users are encountering a bug, it may be too expensive to solve it. The less costly way would be to refund those users, and never hear from them again.

The second reason is that it is difficult to find the edge cases.

An example. I was recently working on a standardization of username/password authentication for my company.

One way was to do it in the same way as it is done by Microsoft, PayPal and others: the bad way. In other words, you don't really care about the edge cases, and try to circumvent them by having passwords with the maximum length of 16 characters, etc.

Those companies know that most users will use a password such as "horse123", and will never experience any problem. On the other hand, I with my 25-characters randomly generated passwords, can't access my Microsoft account from Windows 8 Metro apps done by Microsoft itself, and I can't access my PayPal account, unless I manually tweak the password to be actually different from the one I used when registering.

But they really don't care, because I'm different from 99.9% of users.

The other way is to try to find all the edge cases. For example, if you want to support any unicode character in a password, you should know that some characters may have multiple unicode representations, and while the user will believe that he enters the same password, your app will reply that the password is sometimes right, sometimes wrong, depending on the unicode form. In the same way, some characters should be forbidden: if the system allows \u0014, for example, bad things will happen (like Internet Explorer 10 hanging for 30 seconds when submitting a form with a password containing such characters).

In general, it comes to what is more convenient to do business-wise.

You can spend the next few months searching for edge cases,

or you can implement three or four cool features in your product.

Ask your boss what should you do among those two options.


问:
Are programming languages pretty much "stable" for now?
Recently i have looked at the "timeline" of Programming Languages and while a lot has changed in the past 5-10 years, there are a lot of languages that have pretty much "stayed" the same in their niche/use.

For example, let's take C language. We don't really ever see much languages being developed (correct me if i'm wrong) to try to Unseat C. However, there are a lot of languages that try to do similar things (look at all the SQL/No-SQL languages) Scripting Languages, etc...

Is there a reason for this trend?

Or is it just because C was designed very well ?  and there isn't really any need for new once?

答:
There are lots of languages trying to replace C

First there was C++, and then Java and C# trying to replace that.

Recently Go is trying to replace C directly.

But there is a lot of legacy code and much more legacy experience in C so you can't do things too different and hope to be an instant sucess


问:
How do you stay motivated for hobby projects?
I started seriously programming as a hobbiest, student and then intern about 4 years ago and I've always done small projects on the side as a learning exercise.  Schools over now though, and I spend my days at work as a software developer. I would still love to do projects on the side to learn about areas in computer science that I'm not exposed to at work, but I've noticed that after 8 hours of starring at an IDE it's far to tempting to veg out.  Any time I do get up the gumption to work on something for a few hours lately it's gotten left by the wayside.

Anyone have any advice for sticking with side projects when you spend most of your day coding?

答:
Given that you already have an idea for your hobby project, I would suggest

Write good documentations

Schedule your hobby project in some sense

First of all, it's a hobby project. You may only spend 1-2 hours a day at most, or even only 1-2 hours a week, on your hobby project. It's difficult to remember all the details in such working style, and good documentations help you quickly jump start from the previous pause. A good documentation should keep track on what to be done, what has been done, and why things are done in such way. The documentation can be more important than the actual programming phase of the hobby project.

Also, scheduling some time for the project in advance makes yourself mentally prepared for it. By doing so you're telling yourself it's not the night for gaming/movie/hang-out/dating/whatever, but for your hobby project. It will be easier for you to make up your mind and sit in front of the computer even after a tiresome working day.

If you haven't decided what to do for the hobby project, I will add the followings:

Pick a project that has relatively low entry barrier for you.

Pick a project that really interests you, or

Pick a project that may assist your daily work.

Having some challenges is good, but you may lose your interest and patience quickly if the challenges are just too big. Unless you have some strong incentives (e.g., having strong desire to start a new career path), selecting a project that you already roughly know how to complete may help keep your momentum.

Strong incentives may come from other aspects. An interesting project and a project that facilitates your daily work are some examples. There are lots of fun stuff other than your hobby project, and you need to find a good reason for yourself to continuously work on the hobby project. In regards to the project that facilitates the daily work, it doesn't have to be directly related. A program to automate the editing of your presentation slides; a program to visualize the data. As long as it provides good incentives, it should be a good project that makes you happy to work on.

ContentLicense: CC BY-SA 2.5


答:
If the rules of your card game make a distinction between "effects" and "abilities", you need to make sure that they are different interfaces.  This will keep you from accidentally using one of them where the other is required.

That said, if they are extremely similar, it may make sense to derive them from a common ancestor.  Consider carefully:  do you have reason to believe that "effects" and "abilities" will always necessarily have the same interface?  If you add an element to the effect interface, would you expect to need the same element added to the ability interface?

If so, then you can place such elements in a common feature interface from which they are both derived. If not, then you shouldn't try to unify them -- you will waste your time moving stuff between base and derived interfaces.  However, since you don't intend to actually use the common base interface for anything but "don't repeat yourself", it may not make that much difference.  And, if you stick to that intention, my guess is that if you make the wrong choice at the start, refactoring to fix it later may be relatively simple.


问:
What functionality does dynamic typing allow?
I've been using python for a few days now and I think I understand the difference between dynamic and static typing. What I don't understand is under what circumstances it would be preferred. It is flexible and readable, but at the expense of more runtime checks and additional required unit testing.

Aside from non-functional criteria like flexibility and readability, what reasons are there to choose dynamic typing? What can I do with dynamic typing that isn't possible otherwise? What specific code example can you think of that illustrates a concrete advantage of dynamic typing?

答:
Since you asked for a specific example, I'll give you one.

Rob Conery's Massive ORM is 400 lines of code.  It's that small because Rob is able  to map SQL tables and provide object results without requiring a lot of static types to mirror the SQL tables.  This is accomplished by using the dynamic data type in C#.  Rob's web page describes this process in detail, but it seems clear that, in this particular use case, the dynamic typing is in large part responsible for the brevity of the code.

Compare with Sam Saffron's Dapper, which uses static types; the SQLMapper class alone is 3000 lines of code.

Note that the usual disclaimers apply, and your mileage may vary; Dapper has different goals than Massive does.  I just point this out as an example of something that you can do in 400 lines of code that probably wouldn't be possible without dynamic typing.

Dynamic typing allows you to defer your type decisions to runtime.  That's all.

Whether you use a dynamically-typed language or a statically-typed one, your type choices must still be sensible.   You're not going to add two strings together and expect a numeric answer unless the strings contain numeric data, and if they do not, you're going to get unexpected results.  A statically typed language will not let you do this in the first place.

Proponents of statically type languages point out that the compiler can do a substantial amount of "sanity checking" your code at compile time, before a single line executes. This is a Good Thing™.

C# has the dynamic keyword, which allows you to defer the type decision to runtime without losing the benefits of static type safety in the rest of your code. Type inference (var) eliminates much of the pain of writing in a statically-typed language by removing the need to always explicitly declare types.

Dynamic languages do seem to favor a more interactive, immediate approach to programming.  Nobody expects you to have to write a class and go through a compile cycle to type out a bit of Lisp code and watch it execute.  Yet that's exactly what I'm expected to do in C#.


问:
ASP.NET Webforms developers and web designers: how to interact?
I'm an ASP.NET Webforms developer, and I face some problems when I deal with designers.

Designers always complain about the asp.net server controls. They'd rather just have an html file and create css files along with the required images to go with those. Sometimes, if the design phase is done in advance, I get html files with related css files, but then we face many problems integrating the design with the aspx files (sever controls an telerik controls ... etc).

What I want to ask about is:

How do I overcome these problems? The designers prefer php- and mvc developers because of the problems with .net server controls. I need to know how to interact with the designers in the correct way.

Are there any tools or applications to provide the designers with the rendered (html
page) of the .aspx pages? By that I mean the page in runtime rather than the aspx in Visual Studio. They do use Web Expression but they want the rendered page in html as well.

答:
There is a solution to your issues but it involves a design pattern change to MVP. This is an up-front investment of time that needs serious consideration before start.

Basically, issues that you are experiencing is not new. In short, you need to introduce a view abstraction through interface that identifies the data model that the view supports.

It is very comprehensive topic which makes sense to see pattern as a life example. You would find this example pretty informative for your case - Better Web Forms with the MVP Pattern.

Edit: If above suggestion is too expensive (in terms of time and resources) to follow, i would definitely advice to work with your designer more close. I do believe that communicating your issues within a team should greatly help to resolve impediments in your (designer's and developer's) work. This is a team work and good collaboration of issues to remove all obstacles to perform the work is the way to succeed in a project as a team! This is something that we do in our project.


答:
Duck-typed variables are the first thing everyone thinks of, but in most cases you can get the same benefits through static type inference.

But duck typing in dynamically-created collections is hard to achieve in any other way:

```<code>>>> d = JSON.parse(foo)
>>> d['bar'][3]
12
>>> d['baz']['qux']
'quux'
</code>```

So, what type does JSON.parse return? A dictionary of arrays-of-integers-or-dictionaries-of-strings? No, even that isn't general enough.

JSON.parse has to return some kind of "variant value" that can be null, bool, float, string, array of any of these types recursively, or dictionary from string to any of these types recursively. The main strengths of dynamic typing come from having such variant types.

So far, this is a benefit of dynamic types, not of dynamically-typed languages. A decent static language can simulate any such type perfectly. (And even "bad" languages can often simulate them by breaking type safety under the hood and/or requiring clumsy access syntax.)

The advantage of dynamically-typed languages is that such types cannot be inferred by static type inference systems. You have to write the type explicitly. But in many such cases—including this once—the code to describe the type is exactly as complicated as the code to parse/construct the objects without describing the type, so that still isn't necessarily an advantage.

Title: What functionality does dynamic typing allow?

Body:
I've been using python for a few days now and I think I understand the difference between dynamic and static typing. What I don't understand is under what circumstances it would be preferred. It is flexible and readable, but at the expense of more runtime checks and additional required unit testing.

Aside from non-functional criteria like flexibility and readability, what reasons are there to choose dynamic typing? What can I do with dynamic typing that isn't possible otherwise? What specific code example can you think of that illustrates a concrete advantage of dynamic typing?

Body:
Duck-typed variables are the first thing everyone thinks of, but in most cases you can get the same benefits through static type inference.

But duck typing in dynamically-created collections is hard to achieve in any other way:

>>> d = JSON.parse(foo)
>>> d['bar'][3]
12
>>> d['baz']['qux']
'quux'

So, what type does JSON.parse return? A dictionary of arrays-of-integers-or-dictionaries-of-strings? No, even that isn't general enough.

JSON.parse has to return some kind of "variant value" that can be null, bool, float, string, array of any of these types recursively, or dictionary from string to any of these types recursively. The main strengths of dynamic typing come from having such variant types.

So far, this is a benefit of dynamic types, not of dynamically-typed languages. A decent static language can simulate any such type perfectly. (And even "bad" languages can often simulate them by breaking type safety under the hood and/or requiring clumsy access syntax.)

The advantage of dynamically-typed languages is that such types cannot be inferred by static type inference systems. You have to write the type explicitly. But in many such cases—including this once—the code to describe the type is exactly as complicated as the code to parse/construct the objects without describing the type, so that still isn't necessarily an advantage.


问:
Why would an employer ask for a 'long' code sample?
What would a large project that spanned multiple files and >1000 lines show to an employer that a few individual files and a couple hundred lines couldn't capture?</p>

答: Gives them a nice chunk of code that they can steal without paying you for when they discard you.</p>


问:
Writing a desktop application for progammer from PHP background
I have a client who wants a tool for him to be able to upload his products, enter orders, and keep track of customer details. There are quite a few highly customised requests, which is why he wants the tool custum made.

He does not care much about the interface design - it just has to be usable and provide access to the databade. I've already designed the database.

I have no experience of desktop applications and usually write my web apps in PHP with the Yii framework. But hosting this on a server seems like overkill. I also have .net experience from a few years ago. What would be the best options for writing this as a desktop application?

答: I say C#.  It's a perfectly good programming language, has a nice and easy RAD interface for form design, and is gonna be WAY more responsive then even a locally hosted web application.  You also get the benefit for learning C#, which isn't gonna hurt you.</p>


答:
I would not expect any dramatic changes. Only minor improvements might be seen toward the problems that frameworks try to solve gracefully with less line of code.

Thus, there are more and more abstractions and tools to automate process of template-ing certain code to achieve CRUD code generation. In another word, tools/frameworks are created to sustain fast phase development methodologies and productivity demands. However, fundamental concepts of languages (loops, exception handling, etc.) are remaining almost un-changed.

For example, take T4-code generation in C#. It is another powerful add-on to deal with routine code generation like it is done with text generation in this example code - Code Generation and T4 Text Templates.

Title: Are programming languages pretty much "stable" for now?

Body:
Recently i have looked at the "timeline" of Programming Languages and while a lot has changed in the past 5-10 years, there are a lot of languages that have pretty much "stayed" the same in their niche/use.

For example, let's take C language. We don't really ever see much languages being developed (correct me if i'm wrong) to try to Unseat C. However, there are a lot of languages that try to do similar things (look at all the SQL/No-SQL languages) Scripting Languages, etc...

Is there a reason for this trend?

Or is it just because C was designed very well ?  and there isn't really any need for new once?


答:
As every remotely practical static type system is severely limited compared to the programming language it is concerned with, it cannot express all invariants which code could check at runtime. In order to not circumvent the guarantees a type system attempts to give, it hence opts to be conservative and disallow use cases which would pass these checks, but cannot (in the type system) be proven to.

I'll make an example. Suppose you implement a simple data model to describe data objects, collections of them, etc. which is statically typed in the sense that, if the model says the attribute x of object of type Foo holds an integer, it must always hold an integer. Because this is a runtime construct, you cannot type it statically. Suppose you store the data described in YAML files. You create a hash map (to be handed to a YAML library later), get the x attribute, store it in the map, get that other attribute which just so happens to be a string, ... hold a second? What's the type of the_map[some_key] now? Well shoot, we know that some_key is 'x' and the result hence must be an integer, but the type system can't even begin to reason about this.

Some actively researched type systems may work for this specific example, but these are exceedingly complicated (both for compiler writers to implement and for the programmer to reason in), especially for something this "simple" (I mean, I just explained it in one paragraph).

Of course, today's solution is boxing everything and then casting (or having a bunch of overriden methods, most of which raise "not implemented" exceptions). But this isn't statically typed, it's a hack around the type system to do the type checks at runtime.


答:
ASP.NET is a framework, which abstracts the generated HTML code. This means that you can't be asked to reproduce exactly a given HTML code in an ASP.NET application, unless you have enough budget to rewrite anything which is generated by ASP.NET controls.

It would be up to the stakeholders to decide: either you use ASP.NET controls with their strong points and disadvantages, or you switch to manual HTML (or to ASP.NET MVC), increasing the cost of the current project by thousands of dollars.

The inability to customize HTML in this context is a constraint like any other. Designers should consider this technical constraint in their job. The case is very similar to if the designer would tell you that a text should be displayed in the exact font with exact size: it's a web support, not print, which means that the size of the text will vary.

As for the tools, I'm unaware of tools which will convert plain HTML into an ASP.NET template. How would it possibly guess that a specific table must be converted to a specific ASP.NET control?

Title: ASP.NET Webforms developers and web designers: how to interact?

Body:
I'm an ASP.NET Webforms developer, and I face some problems when I deal with designers.

Designers always complain about the asp.net server controls. They'd rather just have an html file and create css files along with the required images to go with those. Sometimes, if the design phase is done in advance, I get html files with related css files, but then we face many problems integrating the design with the aspx files (sever controls an telerik controls ... etc).

What I want to ask about is:

How do I overcome these problems? The designers prefer php- and mvc developers because of the problems with .net server controls. I need to know how to interact with the designers in the correct way.

Are there any tools or applications to provide the designers with the rendered (html
page) of the .aspx pages? By that I mean the page in runtime rather than the aspx in Visual Studio. They do use Web Expression but they want the rendered page in html as well.


问:
Difference between Unified Process model and agile development
I am confused concerning the unified process model and agile development. When I'm reading about the UP, I'm only understanding that it is an iterative improvement.  Can someone please clarify this?</p>

答:
Unified Process is a detailed and well-defined process.

"Agile" is not a process at all, it is simply a way of saying that one follows the Agile manifesto which, in turn, is just a bunch of values and practices.

So, in short, any process that follows the agile manifesto can be considered agile.


答:
In my experience, one of the core 'yeah, that really works' pieces of an agile approach is the 'Tasks should take less than a day' guideline. If you're estimating things that take longer than a day, you're going to be pretty far off.

Once you've broken them down so you can do that, you've done enough; regardless really of what those things are.


答:
It would be very hard to "unseat" C: it combines the performance of an assembly language with the expressive power of an assembly language, while offering a decent degree of portability. If you desire raw execution speed, would prefer not to code in assembly, and do not care for additional abstraction layers, C perfectly fits the bill. Some development has been going on on the standards side of C, bit it was mostly for minor features.

In contrast, C++ has evolved a lot, adding lambdas and significantly improving the template mechanism. However, the goal was to make C++ more suitable for higher-level tasks, not to improve its speed  - it can be as fast as C already, because it's very close to being a proper super set of C (there are semantic incompatibilities between the two languages).


答:
As languages are used, it will become clear that certain things are missing from the language, and such things will be added.  In hindsight, it will be clear that some things could have been done better, but language designers are generally very hesitant to break backwards compatibility and thus large languages are likely to stay with these details (think C++).

Every so often, people will look at these languages, groan at all the flaws that they find, and decide they can definitely do better from scratch.  Every once in a while, such a language will get a larger audience and perhaps replace an existing language as "the hip thing".  (The old language will still be used in legacy code, of course.)

These changes are going to be slow; language adoption is hard, companies don't want to risk using an untested platform, but changes have happened up to now, and there's no reason to believe they won't continue to happen in the future.


问:
Is it a good practice to create a list of definitions for all symbols and words in a programming language?
After arriving at this point in Learning Python The Hard Way I am wondering if this is a good practice to create a list of symbols and define what they do as noted in bold below, for every programming language. This seems reasonable, and might be very useful to have when jumping between programming languages?

Is this something that programmers do or is it just a waste of effort?

Exercise 22: What Do You Know So Far?
  There won't be any code in this exercise or the next one, so there's no WYSS or Extra Credit either. In fact, this exercise is like one giant Extra Credit. I'm going to have you do a form of review what you have learned so far.

First, go back through every exercise you have done so far and write down every word and symbol (another name for 'character') that you have used. Make sure your list of symbols is complete.

Next to each word or symbol, write its name and what it does. If you can't find a name for a symbol in this book, then look for it online. If you do not know what a word or symbol does, then go read about it again and try using it in some code.

You may run into a few things you just can't find out or know, so just keep those on the list and be ready to look them up when you find them.

Once you have your list, spend a few days rewriting the list and double checking that it's correct. This may get boring but push through and really nail it down.

Once you have memorized the list and what they do, then you should step it up by writing out tables of symbols, their names, and what they do from memory. When you hit some you can't recall from memory, go back and memorize them again.

答:
I'm not a mathematician, so having http://en.wikipedia.org/wiki/List_of_mathematical_symbols available to me is a godsend much of the time.

Likewise, I'm sure people just getting into programming, or even starting a new language may find it just as valuable as I find the above list.

Having said that, generally searching "[language] operators keywords" usually yields everything you need to know.


答:
The only way I ever stay motivated on anything is by having a genuine interest in it (And yes, this can be a problem in commercial work where you're forced to work on stuff which you don't find internally satisfying, but I digress...).

I used to do contrived hobby projects for the sake of learning a new language or framework. Often straight out of random, dry examples from books or websites. This never worked out. I'd always lose motivation and stop after a few sessions.

So the trick for me is to come up with some idea that would actually be useful (either to me or someone I know), and then set myself the task of implementing it in that language/platform. When it's a real world exercise of sorts, and it's a genuinely useful product, I tend to stay much more motivated. When it's a contrived learning project, it's easy to lose the plot.

Title: How do you stay motivated for hobby projects?

Body:
I started seriously programming as a hobbiest, student and then intern about 4 years ago and I've always done small projects on the side as a learning exercise.  Schools over now though, and I spend my days at work as a software developer. I would still love to do projects on the side to learn about areas in computer science that I'm not exposed to at work, but I've noticed that after 8 hours of starring at an IDE it's far to tempting to veg out.  Any time I do get up the gumption to work on something for a few hours lately it's gotten left by the wayside.

Anyone have any advice for sticking with side projects when you spend most of your day coding?


答:
Thank you Google for being so good to programmers with your search algorithms :)

There is no need to exercising and rehearsing anything related some static information, which you may get pretty easily by Googling in 5 sec. I don't imagine any fast phase software development without internet access. Having some glue on what you are searching for will definitely guide you to the right source of the information.

However, without any understanding of topic or related information that might possible lead to it, it would be madness just spend hours in-front of search engine.

Title: Is it a good practice to create a list of definitions for all symbols and words in a programming language?

Body:
After arriving at this point in Learning Python The Hard Way I am wondering if this is a good practice to create a list of symbols and define what they do as noted in bold below, for every programming language. This seems reasonable, and might be very useful to have when jumping between programming languages?

Is this something that programmers do or is it just a waste of effort?

Exercise 22: What Do You Know So Far?
  There won't be any code in this exercise or the next one, so there's no WYSS or Extra Credit either. In fact, this exercise is like one giant Extra Credit. I'm going to have you do a form of review what you have learned so far.

First, go back through every exercise you have done so far and write down every word and symbol (another name for 'character') that you have used. Make sure your list of symbols is complete.

Next to each word or symbol, write its name and what it does. If you can't find a name for a symbol in this book, then look for it online. If you do not know what a word or symbol does, then go read about it again and try using it in some code.

You may run into a few things you just can't find out or know, so just keep those on the list and be ready to look them up when you find them.

Once you have your list, spend a few days rewriting the list and double checking that it's correct. This may get boring but push through and really nail it down.

Once you have memorized the list and what they do, then you should step it up by writing out tables of symbols, their names, and what they do from memory. When you hit some you can't recall from memory, go back and memorize them again.


答:
In the agile scrum methodology, Planning Poker is seen as an effective way of using the whole team to rapidly estimate the effort required for the user stories in a sprint (presuming this is what you are talking about). Otherwise, I wouldn't spend any more than a few minutes estimating a single task that is part of a user story.

I would highly recommend using this consensus-based technique if you are attempting to make estimations for a team of developers.

Planning poker means that you can get some pretty good estimates for every single user story within a single session (no more than 1-2 hours).

Do some reading on this and give it a try!

Also, as a general rule, no task in a user story should exceed 7.5 hours (a single day of work). If it does, you need to break the task into smaller tasks.


答:
You could do something like this anytime you don't fully understand what you've just read. Whether you're reading Bronte's Wuthering Heights or Kuhn's The Structure of Scientific Revolutions or Beethoven's Eroica or just anything... if there are parts that you don't understand, write them down and find out what they mean. Do you get compiler warnings that you don't understand when you compile your program? Write them down along with explanations once you figure them out.

If writing down all the symbols that you don't understand in a Python program helps you, then you'll have learned something, and that's obviously good. You probably won't find most programmers doing exactly this sort of thing when they're working once they know the language because, well, they already know the language.

As you gain experience in a language, you'll think less about the individual symbols and more about the idea that a given bit of code is expressing, so a keeping a list of symbols handy is rather like keeping a words and punctuation marks handy to help you in your reading -- it's simply not necessary.


问:
Does a method to check the file type being uploaded belong in the controller?
If I create a controller that has a method ActionResult UploadFile(HttpPostedFileBase file)  Where is the best place to add the code that will verify that this is a good and useable file?  The reason I ask, is I will have to do more checking than just the file extension.  For instance; check number of columns in spread sheet, check column names, etc..

答:
The best way i have found to determine when i should move code from the "presentation" to the "service" layer is by asking the question... if i change client (from mvc to winforms), is this code "reusable" by both client?

In your case, for example, the code that does a deeper validation, should be in the service layer, not the controller, so it can be used the same way by multiple clients. In other words, you don't have to rewrite it again.
This method works for me and keeps my controllers skinny like an anorexic Victoria's Secret model :)


答: In response to the comments on # of errors per KLOC, well, it sounds like we all under-estimate the prevalence of latent bugs in commercial software :) In mission-critical systems (like flight traffic control), 1 error per 100 lines of code is considered average [http://history.nasa.gov/sts1/pages/computer.html]. Per the same link, the software used on the Challenger space shuttle had approximately 1 error per 10K lines; that code cost $1,000 per line to develop.

Title: Why would an employer ask for a 'long' code sample?

Body: What would a large project that spanned multiple files and >1000 lines show to an employer that a few individual files and a couple hundred lines couldn't capture?</p>


问:
Does it matter to you that a software is "available source" but not "open source"
You probably know the list of open source licenses officially approved by the OSI. Most notably I guess would be the GPL, MIT, [insert your favorite license here].

I recently ran into a project which although was open source (the creator made all source code available), was not officially open source under one of those official licenses.

It released the source, but made no promise to release the source in the future.

It allowed modification suggestions, but made no promises to accept patches and disallowed external distribution of externally-patched versions.

It allowed the use of the software in commercial or paid projects, but disallowed the sale of the software itself.

I suppose it could be called "available source" not open source as we like to think of it.

I can see why the management team of a company wouldn't want to do business with this software. They can't fork it, they can't sell it, they can't create their own version of the software and distribute it or sell it.

But would it matter to you as part of a software engineering team who's just using this software? I can still get my work done with it, I can use it in a project for which I'm paid (but I can't sell the software itself, which I'm not in the business of doing anyway), and I can make changes to the code to make it behave differently for my needs (but I can't make those modifications public), and if I do want those modifications officially made available to others, the approval is up to the project itself and they choose whether to incorporate them in an official release or not.

So we know that a company that wants to base its business on this "available source" software can't do that, but as someone from the software engineering team, would those differences matter to you or do they seem less relevant?

Curious what others think of this.

答:
This does matter quite a bit. Main issues with the "available source" approach that you have described:

You aren't in control of your technological destiny if you don't have the freedom to modify the source. Often hacking the source directly can be preferable to a messy workaround.

You have no guarantee that the software will continue to be maintained, and you don't have the fall-back option of doing it yourself that you get with true open source.

Since it sounds like a custom license, you probably have greater legal risk compared to using something well-known and proven like the GPL or BSD licenses.

If it isn't real open source, you won't get the same level of helpful community around it which is a major advantage for many open source projects

My suggestion: try to persuade the creator to release the software under an open source license. That should be a win/win for everyone - you because you get the software you want under open source licensing, the creator because making the project open source is likely to make the software much more successful in the long run.


问:
Should I listen to my employer and use CASE tools?
My employer (Not a Developer) thinks that CASE tools will help us improve our development process and documentation. I am not sure about that, we are a small team of 5 developers building mobile banking solutions for local clients. I think CASE tools will be a waste of time and money as they need to be purchased and we will need some time before we get used to them and be efficient working with them for modeling and stuff. Code generation is another issue, I really think that the CASE generated code won't be as good as code written by good developers.

I think that if we stick with agile principles, design patterns, use TDD, and keep our code clean. we should be good. And as far as Analysis and Design, I think simple UML diagrams on whiteboard should do the trick. Documentation is good and important, but should be made as little as possible and we should not focus on Docs and forget the code. This is what i think.

Am I correct? or should I listen to my employer and start researching for an appropriate CASE Tool?

答:
Help Your Boss, Help Yourself

You can react or act on this request.

Remember all the "Move Mount Fuji" questions?  If you were in an interview for a job you really wanted, you would not tell the interviewer how stupid the question was, but would keep asking questions and expressing your best ideas about solving it.  In some cultures, you would not ever say no to a boss who actually asked you to move Mount Fuji, but would find a way for you to both save face.

Reframing the Question

If you were to reframe the question into something like,

"Can I buy or otherwise acquire a suite of tools that automate as many
  of the low productivity tasks related to software as possible?"

this assignment becomes much more palatable.  Help your boss (and yourself) by giving him an option with clear tracability to CASE, and one or two Agile / open source / cloud based options.

CASE Revisited

In the '90s, CASE tools might take the form of a suite of tools from Rational that probably included Requisite Pro, Rational Rose, Clear Case, Rational Robot (a test runner), Purify, Pure Coverage, and Quantify, and several other tools that were integrated together.  If you were a MAD shop (Medical, Avionics, Defense) you might use updated versions of these tools to produce extensive and traceable documentation and artifacts that are often required by customers in those markets.

Contact IBM and get a salesman out to give a quote for five licences (or just one floating license).  Add in some training too.  Sharing this quote with your manager may end the talk about CASE tools.  But don't get me wrong.  I like Rational, their chief scientists, and their products, but have mainly accessed them through university site licenses because their price was too high for the companies where I have worked.  If you are approved, at least from my experience, they will treat your right with good support, quality training (usually at a top resort with great food).

Tools for Sale

You still have a great opportunity to go tool shopping.  Agile developers need tools too.  You could buy a suite that gives you documentation support for online story cards, use cases, use case and other UML diagram types.  Atlassian has what I think is a nice suite of tools - Jira for task and bug tracking, Green Hopper for what they describe as Agile project management, Confluence for an intranet wiki, Crucible for online code review, and Bamboo for a continuous integration server.  There are software as a service licenses for these and other tool suites targeted to your needs if you are Agile.

IDE integration is another avenue of getting a year 2012 CASE equivalent.  If you are a Microsoft development house, Visual Team Studio has tools that are of similar scope to what Rational created.  They have some round-trip software engineering, generation of unit test stubs from classes, integration with source control systems, and a bunch of tools for team collaboration.

Open Source Tools

On the open source side, Eclipse and its many plug-ins try to integrate a bunch of open source tools.  I am not sure if Eclipse Modeling Framework is mature or if there are other tools that give effective round-trip software engineer, but last time I looked, it didn't seem very easy to achieve.  The Qt Creator environment integrates with source control, and has some capabilities to help with spot checking from code coverage of changes while you are in the editor.

Iterative Incremental Tool Adoption

An iterative / incremental approach to tool selection can also be very effective.  Open source projects often support single or multiple environments.  Your tool choices may be influenced by the stacks that you use.  There is never a good time to completely shut down development, so adding and training the team in a few smaller tools per quarter may be better than a big bang approach that changes everything at once.

Cloud Tool Solutions

Many of the solutions listed may require servers and relatively complex setup.  There are a lot of options coming into the market that are cloud based and provide software as a service hosted by a provider for a monthly fee.  This may make sense for your team, either short or long term.  Some may have a hosted solution you can use for a quick start, with the option to buy licenses later on.

None of these suggestions is an inexpensive and easy road to instant productivity improvement, but if you may find some of the tools indispensible once you give them a try.


问:
"Do you have any questions for us?" In an interview
You know the prospective company fairly well but are asked "Do you have any questions for us?".  To show interest, what are some of your favorite questions to reply?</p>

答:
I usually ask more about the problem domain, who are the current clients/buyers of the product, financial situation of the company (esp. important if it's small), plans for future development of the product, etc. Also important factors are whether there's cantina, whether I get to work from home occasionally, working hours (flexible or fixed), release schedules, overtime, etc. Everything that can affect the overall quality of my life.

I've been in this business for over 10 years now, in different roles, and I've found out that the people you work with are AT LEAST, if not more, as important as the project/technologies you work on. So ask also whom you will be working with and who will be your leader. When it comes to judging people who have interviewed you, trust your intuition. Did you feel that they were hiding something during the interview, were they evasive, or were they open about things?


问:
Pricing personalized software?
Currently i'm working on a Purchased Order System Application Project for a small scale company.

The Software that i am working on is personalized based on the on their business requirement.

The company told me to create proposal include the price how much is the application is so they can process the check for me.

The person who give me this project is the company supervisor and also a former supply chain supervisor in my employer before which i work also in some of their applications back then.So i want to be fair.

This is my first time to create an application as a sideline so i really never experienced pricing a software even though i am working as full time web  developer in a big company.

Any tips and help ?

答:
I'd go by how much time I invested into it: hours * n where n is the dollar figure that I believe my time is worth.

If you have no idea how much time you invested into it, try digging around for comparable products to see how much they charge.

The person who give me this project is the company supervisor and also a former supply chain > supervisor in my employer before which i work also in some of their applications back then.

This shouldn't matter. Business is business.

So i want to be fair.

You should strive to be fair to all clients, not just those you have a past with.

Title: Pricing personalized software?


答:
The company told me to create proposal include the price how much is the application is so they can process the check for me.

It really depends on how did you negotiate the price. If it is a fixed price, then you need to split your software into logical modules and sub-modules, and price them individually.

However, you also need to include condition of "Change request" - to indicate what would be your charge for that.

Roughly speaking, your estimation accuracy is important to determine what effort it will take you to build this application. I would do the following to find the Total:

multiply your hours by average rate,

add profit 15-30% to overall price

added expenses like operation, hosting charges if applicable,

add taxes. That would be your final total price.

Of course, you may negotiate taking base the estimated price and may also lower your price up to 10%.

Title: Pricing personalized software?

Body:
Currently i'm working on a Purchased Order System Application Project for a small scale company.

The Software that i am working on is personalized based on the on their business requirement.

The company told me to create proposal include the price how much is the application is so they can process the check for me.

The person who give me this project is the company supervisor and also a former supply chain supervisor in my employer before which i work also in some of their applications back then.So i want to be fair.

This is my first time to create an application as a sideline so i really never experienced pricing a software even though i am working as full time web  developer in a big company.

Any tips and help ?


问:
How long to spend estimating programming tasks?
For example, if I break a project into n discrete work products (say classes or functions or components) is there a time t such that n*t is a suitable amount of time to spend on estimation?</p>

答:
What do you get out of your estimates?

Depending on what you work on, accurate individual estimates might be relevant (customer is paying you at the end of the week or task/story is blocking to others and a precise ETA is required) or not (you got 200 stories in the backlog, nobody is going to die if a story shifts for a week, and you're counting on estimate errors to average out ok over a large number of them).

Just spend the minimum amount of time to get an estimate that is good enough for your needs. There is no formula.

Personally, I consider than more than a minute or two means that you're probably estimating the wrong thing (split it up or plan discovery).


问:
Two interfaces with identical signatures
I am attempting to model a card game where cards have two important sets of features:

The first is an effect. These are the changes to the game state that happen when you play the card. The interface for effect is as follows:

```<code>boolean isPlayable(Player p, GameState gs);
void play(Player p, GameState gs);
</code>```

And you could consider the card to be playable if and only if you can meet its cost and all its effects are playable. Like so:

```<code>// in Card class
boolean isPlayable(Player p, GameState gs) {
    if(p.resource < this.cost) return false;
    for(Effect e : this.effects) {
        if(!e.isPlayable(p,gs)) return false;
    }
    return true;
}
</code>```

Okay, so far, pretty simple.

The other set of features on the card are abilities. These abilities are changes to the game state that you can activate at-will. When coming up with the interface for these, I realized they needed a method for determining whether they can be activated or not, and a method for implementing the activation. It ends up being

```<code>boolean isActivatable(Player p, GameState gs);
void activate(Player p, GameState gs);
</code>```

And I realize that with the exception of calling it "activate" instead of "play", Ability and Effect have the exact same signature.

Is it a bad thing to have multiple interfaces with an identical signature? Should I simply use one, and have two sets of the same interface? As so:

```<code>Set<Effect> effects;
Set<Effect> abilities;
</code>```

If so, what refactoring steps should I take down the road if they become non-identical (as more features are released), particularly if they're divergent (i.e. they both gain something the other shouldn't, as opposed to only one gaining and the other being a complete subset)? I'm particularly concerned that combining them will be non-sustainable as soon as something changes.

The fine print:

I recognize this question is spawned by game development, but I feel it's the sort of problem that could just as easily creep up in non-game development, particularly when trying to accommodate the business models of multiple clients in one application as happens with just about every project I've ever done with more than one business influence... Also, the snippets used are Java snippets, but this could just as easily apply to a multitude of object oriented languages.

答:
What you are seeing is basically an artifact of the limited expressiveness of type systems.

Theoretically, if your type system allowed you to accurately specify the behavior of those two interfaces, then their signatures would be different because their behaviors are different. Practically, the expressiveness of type systems is limited by fundamental limitations such as the Halting Problem and Rice's Theorem, so not every facet of behavior can be expressed.

Now, different type systems have differing degrees of expressiveness, but there will always be something which cannot be expressed.

For example: two interfaces which have different error behavior may have the same signature in C#, but not in Java (because in Java exceptions are part of the signature). Two interfaces whose behavior only differs in their side-effects may have the same signature in Java, but will have different signatures in Haskell.

So, it is always possible that you will end up with the same signature for different behaviors. If you think it is important to be able to distinguish between those two behaviors on more than just a nominal level, then you need to switch to a more (or different) expressive type system.


问:
Unit testing internal components
To what extent do you unit test internal/private components of a class/module/package/etc? Do you test them at all or do you just test the interface to the outside world? An example of these internal is private methods.

As an example, imagine a recursive descent parser, which has several internal procedures (functions/methods) called from one central procedure. The only interface to the outside world is the central procedure, which takes a string and returns the parsed information. The other procedures parse different parts of the string, and they are called either from the central procedure or other procedures.

Naturally, you should test the external interface by calling it with sample strings and comparing it with hand-parsed output. But what about the other procedures? Would you test them individually to check that they parse their substrings correctly?

I can think of a few arguments:

Pros:

More testing is always better, and this can help increase code coverage

Some internal components might be hard to give specific inputs (edge cases for example) by giving input to the external interface

Clearer testing. If an internal component has a (fixed) bug, a test case for that component makes it clear that the bug was in that specific component

Cons:

Refactoring becomes too painful and time-consuming. To change anything, you need to rewrite the unit tests, even if the users of the external interface are not affected

Some languages and testing frameworks don't allow it

What are your opinions?

答: Split it into multiple parts with a functional meaning, eg ParseQuotedString(), ParseExpression(), ParseStatement(), ParseFile() and make them all public. How likely is it that that your syntax changes so much that these become irrelevant?

Title: Unit testing internal components


问:
How to update dependency during runtime in my .NET application?
I have a server-client application. Sometimes the server is updated which requires some DLLs in the client to be updated as well (The DLLs are the dependencies of the main executable). For now, we have to close the client, manually deploy the DLLs, and then start the client again. This is kind of an inconvenience because the client is an automated application, so normally it doesn't need any user intervention.

Is it possible for this to be done automatically without restart or user intervention? Like, the client would download the latest DLL, and replace the current one?

答:
Yes, it is possible in many different ways. The easiest way is called ClickOnce Deployment.

This a very convenient deployment mechanism for smart client applications built for the .NET Framework. You may get detailed information on how to set your updates to be done automatically when your clients are starting. Here is a good reference on how to administrate the process - Administering ClickOnce Deployments.


答:
This is an ordinary sandbox model (the one which is used with plugins/addins). Instead of calling the libraries directly, you load them in a different AppDomain. Doing this actually allows you to update the corresponding libraries while the application is still running.

If you want to automate the process, the client application can monitor the directory with those libraries, and load newer ones to the sandboxed AppDomain when they are available.

Note that:

Using sandbox is not as easy as not using it, and you must be ready to have some issues. The two I had were that I was unable to put the UI elements in the sandboxed libraries and that cache stopped working when using sandbox.

If there are lots of exchange between the sandbox and the application itself, you may see the performance of your application decrease.

With a sandbox, you will not be able to unload, update and load the updated version of the library if the application is running at the same moment the code from this library. It's just not possible, and doesn't make sense.

This is probably also why the browsers like Chrome and Firefox still need to restart to finish the updates.

If this is your case, you may search for a way to indicate to the code from the library that it must stop, since the library will be unloaded.

The overall architecture of your application would be more complex, for sure. Does it worth it? Couldn't you schedule a background update, i.e. every night, if a new version is available, the application will just stop entirely, update itself (through an updater executable), and then be restarted by the updater?

Title: How to update dependency during runtime in my .NET application?

Body:
I have a server-client application. Sometimes the server is updated which requires some DLLs in the client to be updated as well (The DLLs are the dependencies of the main executable). For now, we have to close the client, manually deploy the DLLs, and then start the client again. This is kind of an inconvenience because the client is an automated application, so normally it doesn't need any user intervention.

Is it possible for this to be done automatically without restart or user intervention? Like, the client would download the latest DLL, and replace the current one?


问:
Is a code review which uses only code comments a good idea?

Preconditions

Team uses DVCS

IDE supports comments parsing (like TODO and etc.)

Tools like CodeCollaborator are expensive for budget

Tools like gerrit are too complex for install or not usable

Workflow

Author publishes somewhere on central repo feature branch

Reviewer fetch it and start review

In case of some question/issue reviewer create comment with special label, like "REV". Such label MUST not be in production code -- only on review stage:

```<code>$somevar = 123;
// REV Why do echo this here?
echo $somevar;
</code>```

When reviewer finish post comments -- it just commits with stupid message "comments" and pushes back

Author pulls feature branch back and answer comments in similar way or improve code and push it back

When "REV" comments have gone we can think, that review has successfully finished.

Author interactively rebases feature branch, squashes it to remove those "comment" commits and now is ready to merge feature to develop or make any action that usualy could be after successful internal review

IDE support

I know, that custom comment tags are possible in eclipse & netbeans. Sure it also should be in blablaStorm family.

Questions

Do you think this methodology is viable?

Do you know something similar?

What can be improved in it?

答:
The idea is actually very nice. Contrary to common workflows, you keep the review directly in code, so technically, you don't need anything but text editor to use this workflow. The support in the IDE is nice too, especially the ability to display the list of reviews in the bottom.

There are still a few drawbacks:

It works fine for very small teams, but larger teams will require tracking over what were reviewed, when, by whom and with which result. While you actually have this sort of tracking (version control allows to know all that), it's extremely difficult to use and search, and will often require a manual or semi-manual search through the revisions.

I don't believe that the reviewer has enough feedback from the reviewee to know how the reviewed points were actually applied.

Imagine the following situation. Alice is reviewing for the first time the code of Eric. She notices that Eric, a young developer, used the syntax which is not the most descriptive in the programming language actually used.

Alice suggests an alternative syntax, and submits the code back to Eric. He rewrites the code using this alternative syntax that he believes understanding correctly, and removes the corresponding // BLA comment.

The next week, she receives the code for the second review. Would she be able to actually remember that she made this remark during her first review, in order to see how Eric solved it?

In a more formal review process, Alice could immediately see that she made a remark, and see the diff of the relevant code, in order to notice that Eric misunderstood the syntax she told him about.

People are still people. I'm pretty sure that some of those comments will end up in production code, and some will remain as a garbage while being completely outdated.

Of course, the same problem exists with any other comment; for example there are lots of TODO comments in production (including the most useful one: "TODO: Comment the code below."), and lots of comments which were not updated when the corresponding code was.

For example, the original author of the code or the reviewer may leave, and the new developer would not understand what the review says, so the comment will remain forever, awaiting that somebody would be too courageous to wipe it out or to actually understand what it says.

This does not replace a face-to-face review (but the same problem applies as well to any other more formal review which is not done face-to-face).

Especially, if the original review requires explanation, the reviewer and the reviewee will start a sort of a discussion. Not only you will find yourself with large BLA comments, but those discussions will also pollute the log of the version control.

You may also encounter minor issues with the syntax (which also exists for TODO comments). For example, what if a long "// BLA" comment spawns on several lines, and somebody decides to write it this way:

```<code>// BLA This is a very long comment which is way beyond 80 characters, so it actually
// fills more then one line. Since the next lines start with slashes, but not "BLA"
// keyword, the IDE may not be able to show those lines, and display only the first one.
</code>```

And finally as a minor and very personal note: don't choose "BLA" as a keyword. It sounds ugly. ;)

Body:
The idea is actually very nice. Contrary to common workflows, you keep the review directly in code, so technically, you don't need anything but text editor to use this workflow. The support in the IDE is nice too, especially the ability to display the list of reviews in the bottom.

There are still a few drawbacks:

It works fine for very small teams, but larger teams will require tracking over what were reviewed, when, by whom and with which result. While you actually have this sort of tracking (version control allows to know all that), it's extremely difficult to use and search, and will often require a manual or semi-manual search through the revisions.

I don't believe that the reviewer has enough feedback from the reviewee to know how the reviewed points were actually applied.

Imagine the following situation. Alice is reviewing for the first time the code of Eric. She notices that Eric, a young developer, used the syntax which is not the most descriptive in the programming language actually used.

Alice suggests an alternative syntax, and submits the code back to Eric. He rewrites the code using this alternative syntax that he believes understanding correctly, and removes the corresponding // BLA comment.

The next week, she receives the code for the second review. Would she be able to actually remember that she made this remark during her first review, in order to see how Eric solved it?

In a more formal review process, Alice could immediately see that she made a remark, and see the diff of the relevant code, in order to notice that Eric misunderstood the syntax she told him about.

People are still people. I'm pretty sure that some of those comments will end up in production code, and some will remain as a garbage while being completely outdated.

Of course, the same problem exists with any other comment; for example there are lots of TODO comments in production (including the most useful one: "TODO: Comment the code below."), and lots of comments which were not updated when the corresponding code was.

For example, the original author of the code or the reviewer may leave, and the new developer would not understand what the review says, so the comment will remain forever, awaiting that somebody would be too courageous to wipe it out or to actually understand what it says.

This does not replace a face-to-face review (but the same problem applies as well to any other more formal review which is not done face-to-face).

Especially, if the original review requires explanation, the reviewer and the reviewee will start a sort of a discussion. Not only you will find yourself with large BLA comments, but those discussions will also pollute the log of the version control.

You may also encounter minor issues with the syntax (which also exists for TODO comments). For example, what if a long "// BLA" comment spawns on several lines, and somebody decides to write it this way:

// BLA This is a very long comment which is way beyond 80 characters, so it actually
// fills more then one line. Since the next lines start with slashes, but not "BLA"
// keyword, the IDE may not be able to show those lines, and display only the first one.

And finally as a minor and very personal note: don't choose "BLA" as a keyword. It sounds ugly. ;)


问:
Why don't computers store decimal numbers as a second whole number?
Computers have trouble storing fractional numbers where the denominator is something other than a solution to 2^x.  This is because the first digit after the decimal is worth 1/2, the second 1/4 (or 1/(2^1) and 1/(2^2)) etc.

Why deal with all sorts of rounding errors when the computer could have just stored the decimal part of the number as another whole number (which is therefore accurate?)

The only thing I can think of is dealing with repeating decimals (in base 10), but there could have been an edge solution to that (like we currently have with infinity).

答:
The short answer is that floating point was designed for scientific calculations. It can store a number with (up to) a specified number of significant digits, which fits closely with how precision is measured in most scientific calculations.

That tends to be supported in hardware largely because scientific calculations have tended to be the ones that benefited the most from hardware support. For one example, financial calculations are often done with other formats -- but financial software usually does little enough real calculation that even though the necessary formats are only supported in software, performance remains perfectly adequate for most financial software.


答:
You should look into having your application implement MEF (Managed Extensibility Framework). With MEF you can easily load your DLL dependencies from a Directory Catalog, and write code to refresh the catalog when the directory contents change. This can all be done on the fly without the app having to be stopped and restarted, if done right.

It's not a code-free solution, though. You have to write the MEF functionality in your main app that loads the catalog, and the DLLs would have to be written to accommodate MEF.


问:
Is verification and validation part of testing process?
Based on many sources I do not believe the simple definition that aim of testing is to find as many bugs as possible - we test to ensure that it works or that it does not. E.g. followint are goals of testing form ISTQB:

Determine that (software products) satisfy specified requirements ( I think its verificication)

Demonstrate that (software products) are fit for purpose (I think that is validation)

Detect defects

I would agree that testing is verification, validation and defect detection. Is that correct?

答:
From Wikipedia : "... In other words, validation ensures that the product actually meets the user's needs, and that the specifications were correct in the first place, while verification is ensuring that the product has been built according to the requirements and design specifications. Validation ensures that "you built the right thing". Verification ensures that "you built it right". Validation confirms that the product, as provided, will fulfill its intended use."

You can't test user's needs and check if the specifications were correct by code. So validation is not done by testing.

Verification supposes that your requirements and design are correct, so you can test it by writing code(testing).


答:
You can use the other suggestions - Cost+ Pricing - work out what it cost you, add some profit and charge that. It's valid and widely used in competitive markets, and will put food on your table, but nothing more.

Software is rarely competitive, so you use Value Add pricing - what value is the software to your customer - if he's an iFanBoy, you can often sell a useless app that does nothing for $10.00. If its a multi billion dollar multinational and your app saves them 0.1% of annual revenues you can charge 0.1% of multi billion dollars, no matter how much it cost you to develop. In your case, if your app makes/saves your customer $X/annum, charge him between $X and $3X (hint - < 1 year comes out of OP-EX (certain sale), 2 years needs budget (hard sale), and 3 years needs financial departments approval (practically impossible sale) )

Title: Pricing personalized software?


答:
For the real world, testing is verification and validation of the software that is meets the software's requirements (business/functional/non-functional). The aim of these is to determine if the software is fit for purpose. Any behavior that does not meet the requirements of the application is a defect - the severity of which will need to be weighted up before determining if the software is fit for purpose. </p>

<p>Low severity defects are probably not show-stoppers to passing the software onto a production type use, High severity may require a fix to be produced. In the real world all software has defects, some are coding issues and others are from missing requirements - which may not be tested for because you cannot test a unknown requirements. </p>

Title: Is verification and validation part of testing process?

Body:
Based on many sources I do not believe the simple definition that aim of testing is to find as many bugs as possible - we test to ensure that it works or that it does not. E.g. followint are goals of testing form ISTQB:

Determine that (software products) satisfy specified requirements ( I think its verificication)

Demonstrate that (software products) are fit for purpose (I think that is validation)

Detect defects

I would agree that testing is verification, validation and defect detection. Is that correct?

Body:
For the real world, testing is verification and validation of the software that is meets the software's requirements (business/functional/non-functional). The aim of these is to determine if the software is fit for purpose. Any behavior that does not meet the requirements of the application is a defect - the severity of which will need to be weighted up before determining if the software is fit for purpose.

Low severity defects are probably not show-stoppers to passing the software onto a production type use, High severity may require a fix to be produced. In the real world all software has defects, some are coding issues and others are from missing requirements - which may not be tested for because you cannot test a unknown requirements.


答: it would show you're likely to hand their code to a competitor if asked to produce a code sample during a job interview.</p>


答: It all depends on your definition of "verification". For example, formal verification is usually not something done by a QA team, but is instead a responsibility of the developers. Almost nobody does formal verification because of the high cost associated with it (knowledge gap and resources needed).</p>


答:
There are many definitions of verification and validation. Many people even use the V&V tag to group both in a single activity. The aim is to make sure that software makes right things and makes things right. Whether it is to check compliance with requirements or try to find bugs is not essential at this level.

Testing is one out of many techniques to verification and validation, not the other way. Code review is another one, and formal verification, with mathematical proofs yet another one.

Nonetheless, testing should be performed with the aim to find bugs, not with the aim to check compliance with requirements.

The main difference is in the mind of the tester. It is far easier to build a test case showing that sofware works as intended (checking compliance), than to build a test case showing that software fails (finding bugs).

A great tester is passionate about breaking software, not about exercizing it in a safe way.


问:
Javascript naming conventions
I am from Java background and am new to JavaScript. I have noticed many JavaScript methods using single character parameter names, such as in the following example.

```<code>doSomething(a,b,c)
</code>```

I don't like it, but a fellow JavaScript developer convinced me that this is done to reduce the file size, noting that JavaScript files have to be transferred to the browser.

Then I found myself talking to another developer. He showed me the way that Firefox will truncate variable names to load the page faster.  Is this a standard practice for web browsers?

What are the best-practice naming conversions that should be followed when programming in JavaScript? Does identifier length matter, and if so, to what extent?

答:
Identifier length does not matter. As said by others, in production Minification can be used to reduce script download time. In fact, an acceptable coding/naming convention should be followed, especially because JavaScript is a quirky language and for so long JavaScript has been neglected as just a thing to get the job done. If you are looking for a place for naming convention, Google JavaScript Style Guide is a good place. It suggests,

functionNamesLikeThis, e.g., getCashbackData() {}

variableNamesLikeThis, e.g., var alertInterval = 10;

ClassNamesLikeThis, e.g., var CustomerOrder = { getOrderLines: function () {} }

EnumNamesLikeThis, e.g., var ColorOfChoice = { White: "#FFFFFF" }

methodNamesLikeThis, e.g., var CustomerOrder = { getOrderLine: function () {} }

SYMBOLIC_CONSTANTS_LIKE_THIS, e.g., var EPOCH_UNIX = "01011970"

Title: Javascript naming conventions