问:
How could I avoid a distributed deadlock during a mutual connection between two nodes?
Suppose we have two peer nodes: the first node can send a connection request to the second one, but also the second one can send a connection request to the first one. How to avoid a double connection between the two nodes? To resolve this issue, it would be sufficient to make sequential the operations performed for creating inbound or outbound TCP connections.

This means that each node should process sequentially each new connection creation operation, both for incoming connections and for outgoing connections. In this way, maintaining a list of connected nodes, before accepting a new incoming connection from a node or before sending a connection request to a node, it will be sufficient to check if this node is already present in the list.

In order to make sequential the operations of creating connections, it is sufficient to perform a lock on the list of connected nodes: in fact, for each new connection, the identifier of the new connected node is added to this list. However, I wonder if this approach can cause distributed deadlock:

the first node could send a connection request to the second one;

the second node could send a connection request to the first one;

assuming that the two connection requests are not asynchronous, both nodes lock any incoming connection requests.

How could I solve this problem?

UPDATE: However, I still have to lock on the list every time a new (incoming or outgoing) connection is created, since other threads may access this list, then the problem of deadlock would still remain.

UPDATE 2: Based on your advice I wrote an algorithm to prevent mutual acceptance of a login request. Since each node is a peer, it could have a client routine to send new connection requests and a server routine to accept incoming connections.

```<code>ClientSideLoginRoutine() {
    for each (address in cache) {
        lock (neighbors_table) {
            if (neighbors_table.contains(address)) {
                // there is already a neighbor with the same address
                continue;
            }
            neighbors_table.add(address, status: CONNECTING);

        } // end lock

        // ...
        // The node tries to establish a TCP connection with the remote address
        // and perform the login procedure by sending its listening address (IP and port).
        boolean login_result = // ...
        // ...

        if (login_result)
            lock (neighbors_table)
                neighbors_table.add(address, status: CONNECTED);

    } // end for
}

ServerSideLoginRoutine(remoteListeningAddress) {
    // ...
    // initialization of data structures needed for communication (queues, etc)
    // ...

    lock(neighbors_table) {
        if(neighbors_table.contains(remoteAddress) && its status is CONNECTING) {
            // In this case, the client-side on the same node has already
            // initiated the procedure of logging in to the remote node.

            if (myListeningAddress < remoteListeningAddress) {
                refusesLogin();
                return;
            }
        }
        neighbors_table.add(remoteListeningAddress, status: CONNECTED);

    } // end lock
}
</code>```

Example:
The IP:port of node A is A:7001 - The IP:port of node B is B:8001.

Suppose that the node A has sent a login request to the node B:8001.
In this case, the node A calls the login routine by sending by sending its own listening address (A:7001).
As a consequence, the neighbors_table of node A contains the address of the remote node (B:8001): this address is associated with the CONNECTING state.
Node A is waiting for node B accept or deny the login request.

Meanwhile, the node B also may have sent a connection request to the address of node A (A:7001), then node A may be processing the request of the node B.
So, the neighbors_table of node B contains the address of the remote node (A:7001): this address is associated with the CONNECTING state.
Node B is waiting for node A accept or deny the login request.

If the server side of node A rejects the request from B:8001, then I must be sure that server side of node B will accept the request from A:7001.
Similarly, if the server side of node B rejects the request from A:7001, then I must be sure that server side of node A will accept the request from B:8001.

According to the "small address" rule, in this case the node A will reject the login request by the node B, while node B will accept the request from node A.

What do you think about that?

答:
If I understand, the problem you're trying to avoid goes like this:

Node1 requests connection from node 2

Node1 locks connection list

Node2 requests connection from node 1

Node2 locks connection list

Node2 receives connection request from node1, rejects because list is locked

Node1 receives connection request from node2, rejects because list is locked

Neither one ends up connecting to each other.

I can think of a couple different ways to deal with this.

If you try to connect to a node, and it rejects your request with a "list locked" message, wait a random number of milliseconds before trying again.  (The randomness is critical. It makes it much less likely that both will wait for the exact same amount of time and repeat the same problem ad infinitum.)

Synchronize both systems' clocks with a time server, and send a timestamp along with the connection request.  If a connection request comes in from a node that you're currently trying to connect to, then both nodes agree that whichever one tried to connect first wins, and the other connection gets closed.


问:
Is Object Oriented Programming a solution to complexity?
Do you think Object Oriented Programming is a solution to complexity. Why? This topic may be a bit controversial but my intentions to know the answer of Why from the experts here !</p>

答:
I think the current mainstream definition of OOP is not a good solution for managing complexity.

If you go back to its roots, I believe Alan Kay was influenced by "lisp" a great deal.

Because Lisp hasn't been corrupted by mainstream adoption, it probably managed to conserve its core values. So I think looking at how lisp tackles this problem of complexity might gives us some insight, and we can use it as a basis to sort of judge how useful is OOP at dealing with complexity.

If you look at the end of the "Lecture 3a: Henderson Escher Example" of SICP, Hal Abelson proposes that complexity is managed not by breaking the task into smaller subtasks, but by creating layers of abstraction. At the highest level, you express the solution to the complicated problem in terms of the the solution to the lower level of abstraction.

I think OOP was originally intended as a mechanism to create these layers of abstractions.

Unfortunately nowadays, OOP is (ab)used to write spaghetti code/structures.

I will make up an example: an FPS multi-player game.

At the highest level, the game works by having a bunch of players running around a map and shooting at each other using weapons.

At the next lower level, we have to talk about maps and weapons and players. Perhaps we can talk about them as physical objects that interact within the world of the game.

At the next lower level, we can talk about how objects interact physically (movement, collisions, etc).

And so on and so forth.

What this means, (and I'm sort of quoting from SICP..), is that at each layer, we not only solve a particular specific problem, but a class of problems that sort of fall in the neighborhood of the problem we're trying to solve. So if there's a small change in the problem's description, it would likely require only a small change in the solution.

So, the wise way to use OOP is to create layers of abstractions, at each level of abstraction, you solve the problem at hand using the "objects" from the level that's directly below.

Here's the bit I was quoting from the lecture: http://www.youtube.com/watch?v=CYtrfncMqHQ

ContentLicense: CC BY-SA 2.5


问:
Can my company give IP rights away for an application I wrote off hours to another startup?
I am an intern for a health company (unpaid), let's call it Company A and I noticed that they are using a lot of paper form for things that can be done on the computer. Excel files for things that shouldn't be in Excel. So I wanted to improve on my programming and figured that it was the best opportunity to do.

I developed a couple of apps for their use. All these applications were outside company time. One application I did and they love and one of the director has a brother who has a health start up company. He wants me to give over my source code so his brother's company can further develop it and maybe sell it (I am out of the equation).

I have no intention of handing over my code as I put a lot of time outside doing it but I also don't want to burn bridges with anyone in the company. I can't go to the director and tell him "I don't think so".

I am fine with demoing to the brother how it works but the line is giving up my code. If they want to build something like it then they can go right ahead I have no problem with it.

What is the correct way of approaching this and do they have the right to do this to me?

Edit: there is no contract I never signed anything

答:
(IANAL, etc)

Assuming you're American, it's safe to say you have no legal or contractual obligation to give them anything, certainly not without compensation. A better question is whether or not your unpaid internship is technically legal itself, though you may not want to go there unless they try and be difficult about this.

Check this for the guidelines about unpaid internships.

Specifically: "The employer that provides the training derives no immediate advantage from the activities of the intern; and on occasion its operations may actually be impeded;"

ContentLicense: CC BY-SA 3.0


答: You can try an "optimistic" approach: connect first, then disconnect if you detect a concurrent mutual connection. This way you would not need to keep out the connection requests while you are making new connections: when an incoming connection is established, lock the list, and see if you have an outgoing connection to the same host. If you do, check host's address. If it is smaller than yours, disconnect your outgoing connection; otherwise, disconnect the incoming one. Your peer host will do the opposite, because the addresses will compare differently, and one of the two connections will be dropped. This approach lets you avoid retrying your connections, and potentially helps you to accept more connection requests per unit of time.</p>

Title: How could I avoid a distributed deadlock during a mutual connection between two nodes?

Body:
Suppose we have two peer nodes: the first node can send a connection request to the second one, but also the second one can send a connection request to the first one. How to avoid a double connection between the two nodes? To resolve this issue, it would be sufficient to make sequential the operations performed for creating inbound or outbound TCP connections.

This means that each node should process sequentially each new connection creation operation, both for incoming connections and for outgoing connections. In this way, maintaining a list of connected nodes, before accepting a new incoming connection from a node or before sending a connection request to a node, it will be sufficient to check if this node is already present in the list.

In order to make sequential the operations of creating connections, it is sufficient to perform a lock on the list of connected nodes: in fact, for each new connection, the identifier of the new connected node is added to this list. However, I wonder if this approach can cause distributed deadlock:

the first node could send a connection request to the second one;

the second node could send a connection request to the first one;

assuming that the two connection requests are not asynchronous, both nodes lock any incoming connection requests.

How could I solve this problem?

UPDATE: However, I still have to lock on the list every time a new (incoming or outgoing) connection is created, since other threads may access this list, then the problem of deadlock would still remain.

UPDATE 2: Based on your advice I wrote an algorithm to prevent mutual acceptance of a login request. Since each node is a peer, it could have a client routine to send new connection requests and a server routine to accept incoming connections.

```<code>ClientSideLoginRoutine() {
    for each (address in cache) {
        lock (neighbors_table) {
            if (neighbors_table.contains(address)) {
                // there is already a neighbor with the same address
                continue;
            }
            neighbors_table.add(address, status: CONNECTING);

        } // end lock

        // ...
        // The node tries to establish a TCP connection with the remote address
        // and perform the login procedure by sending its listening address (IP and port).
        boolean login_result = // ...
        // ...

        if (login_result)
            lock (neighbors_table)
                neighbors_table.add(address, status: CONNECTED);

    } // end for
}

ServerSideLoginRoutine(remoteListeningAddress) {
    // ...
    // initialization of data structures needed for communication (queues, etc)
    // ...

    lock(neighbors_table) {
        if(neighbors_table.contains(remoteAddress) && its status is CONNECTING) {
            // In this case, the client-side on the same node has already
            // initiated the procedure of logging in to the remote node.

            if (myListeningAddress < remoteListeningAddress) {
                refusesLogin();
                return;
            }
        }
        neighbors_table.add(remoteListeningAddress, status: CONNECTED);

    } // end lock
}
</code>```

Example:
The IP:port of node A is A:7001 - The IP:port of node B is B:8001.

Suppose that the node A has sent a login request to the node B:8001.
In this case, the node A calls the login routine by sending by sending its own listening address (A:7001).
As a consequence, the neighbors_table of node A contains the address of the remote node (B:8001): this address is associated with the CONNECTING state.
Node A is waiting for node B accept or deny the login request.

Meanwhile, the node B also may have sent a connection request to the address of node A (A:7001), then node A may be processing the request of the node B.
So, the neighbors_table of node B contains the address of the remote node (A:7001): this address is associated with the CONNECTING state.
Node B is waiting for node A accept or deny the login request.

If the server side of node A rejects the request from B:8001, then I must be sure that server side of node B will accept the request from A:7001.
Similarly, if the server side of node B rejects the request from A:7001, then I must be sure that server side of node A will accept the request from B:8001.

According to the "small address" rule, in this case the node A will reject the login request by the node B, while node B will accept the request from node A.

What do you think about that?


答: In the USA, unless you are receiving "course credit" at your college (or actual pay as you stated you are not), then there is no legal "consideration" (compensation), which is necessary for a contract to be formed.  I am not a lawyer, but this is basic high school level knowledge of contracts.  A contract MUST have "consideration" for both parties, or it is NOT a contract.  If it is completely unpaid and you receive no other consideration, then the firm is violating the federal minimum wage regulations AND your IP is still your IP (if you protect it).  Unless your IP is really of considerable value, you should be careful to be too hasty or too angry...."one hand washes the other" in business...Again, I'm not a lawyer.  Use your best discretion.</p>

Title: Can my company give IP rights away for an application I wrote off hours to another startup?

Body:
I am an intern for a health company (unpaid), let's call it Company A and I noticed that they are using a lot of paper form for things that can be done on the computer. Excel files for things that shouldn't be in Excel. So I wanted to improve on my programming and figured that it was the best opportunity to do.

I developed a couple of apps for their use. All these applications were outside company time. One application I did and they love and one of the director has a brother who has a health start up company. He wants me to give over my source code so his brother's company can further develop it and maybe sell it (I am out of the equation).

I have no intention of handing over my code as I put a lot of time outside doing it but I also don't want to burn bridges with anyone in the company. I can't go to the director and tell him "I don't think so".

I am fine with demoing to the brother how it works but the line is giving up my code. If they want to build something like it then they can go right ahead I have no problem with it.

What is the correct way of approaching this and do they have the right to do this to me?

Edit: there is no contract I never signed anything


答:
When one node sends a request to another, it could include a random 64-bit integer.  When a node gets a connection request, if it has already sent one of it's own, it keeps the one with the highest number and drops the others.  For example:

Time 1: A tries to connect to B, sends the number 123.

Time 2: B tries to connect to A, sends the number 234.

Time 3: B receives A's request.  Since B's own request has a higher number, it denies A's request.

Time 4: A receives B's request.  Since B's request has a higher number, A accepts it and drops its own request.

To generate the random number, make sure you seed your random number generator with /dev/urandom, rather than using the default seeding of your random number generator, which is often based on wall clock time: there's a not-ignorable chance that two nodes will get the same seed.

Instead of random numbers, you could also distribute numbers ahead of time (i.e. just number all machines from 1 to n), or use a MAC address, or some other way of finding a number where the probability of collision is so small as to be ignorable.


问:
How are new[] and malloc implemented in Windows?
So when you call malloc or new [] from your C/C++ application, how does the CRT translate it into Windows API calls?</p>

答:
Windows has a HeapAlloc function in the win32 API, maybe it's used.

The major point is that this is not so much related to Windows as it is to your C or C++ implementation. They implement malloc and how new works. So you should go about finding out how malloc and new are implemented in, for example, Visual C++.

I am not a C++ expert, but iirc, you can overload new; so there may be more going on there.


问:
How to share methods and properties between custom web controls
I'm building some custom web controls in .NET using C#.  The controls inherit from the standard web controls, and add additional properties and functionality (e.g. I'm creating an 'extendedTextBox' and I'm adding a 'required' property, which if set to 'true' will add a .NET required field validator to the control automatically.

I'm doing this for a number of web controls (e.g. radioButtonList, textArea).  They share some common properties and methods, for example I have an AddRequiredFieldValidator method that uses some of the extended properties I've added.  I'd like to share the common properties and methods.  I've tried adding the methods to a separate class as extension methods for a web control.  To achieve this I've implemented an interface that defines the additional shared properties, and am using it like this:

```<code>public interface IExtendendControl
{
    string RequiredMessage { get; set; }
    string ValidatorCssClass { get; set; }
    bool ClientScript { get; set; }
    RequiredFieldValidator rfv { get; set; }
}

public static class ExtendedControlExtensions : IExtendendControl
{
    public static void AddRequiredFieldValidator(this IExtendendControl control)
    {
        control.rfv = new RequiredFieldValidator();
        control.rfv.ErrorMessage = control.RequiredMessage;
        ConfigureAndAddValidator(control, control.rfv);
    }

    public static void ConfigureAndAddValidator(this IExtendendControl control, BaseValidator validator)
    {
        validator.ControlToValidate = control.ID;
        validator.Display = ValidatorDisplay.Dynamic;
        validator.CssClass = "validationMessage ";
        validator.CssClass += control.ValidatorCssClass;
        validator.EnableClientScript = control.ClientScript;
        control.Controls.Add(validator);
    }
}
</code>```

Trouble is that the 'ConfigureAndAddValidator' method now doesn't know anything about the 'ID' or 'ClientScript' properties of the control since 'IExtendedControl' only defines the custom properties, not the standard properties of a web control.  So I tried adding a base class that inherits from WebControl and implements the interface, like this:

```<code>public interface IExtendendControl
{
    string RequiredMessage { get; set; }
    string ValidatorCssClass { get; set; }
    bool ClientScript { get; set; }
    RequiredFieldValidator rfv { get; set; }
}

public class BaseExtendedControl : WebControl, IExtendendControl
{
    public string RequiredMessage { get; set; }
    public string ValidatorCssClass { get; set; }
    public bool ClientScript
    {
        get
        { return ClientScript = true; }
        set { }
    }
    public RequiredFieldValidator rfv
    {
        get
        { return rfv = new RequiredFieldValidator(); }
        set { }
    }
}

public static class ExtendedControlHelper : IExtendendControl
{
    public static void AddRequiredFieldValidator(this BaseExtendedControl control)
    {
        BaseExtendedControl extendedControl = (BaseExtendedControl)control;
        extendedControl.rfv = new RequiredFieldValidator();
        extendedControl.rfv.ErrorMessage = extendedControl.RequiredMessage;
        ConfigureAndAddValidator(control, extendedControl.rfv);
    }

    public static void ConfigureAndAddValidator(this BaseExtendedControl control, BaseValidator validator)
    {
        validator.ControlToValidate = control.ID;
        validator.Display = ValidatorDisplay.Dynamic;
        validator.CssClass = "validationMessage ";
        validator.CssClass += control.ValidatorCssClass;
        validator.EnableClientScript = control.ClientScript;
        control.Controls.Add(validator);
    }
}
</code>```

The trouble now is that in my extendedTextBox class I can't cast my extendedTextBox as a 'BaseExtendedControl' to use the extension methods, as the extendedTextBox inherits from the standard TextBox class like this:

```<code>public class ExtendedTextBox : TextBox, IExtendendControl
</code>```

so there's no common base to cast ExtendedTextBox as 'BaseExtendedControl' as it doesn't inherit from it.  I also can't just pass the extended web control objects as a parameter into the shared methods as the extended controls are of different types (e.g. they inherit from TextBox, RadioButtonList and so on).  If I specify the expected type being passed into 'standard' methods as 'WebControl' it doesn't work as the extended controls have the additional properties.

As I can't use true multiple inheritance in C#, how would I design this to be able to share the methods and properties?

答:
Thanks for the replies.  Fuex - you put me on the right track, here's the final code which includes an a extended TextBox control and extended RadioButtonList control.

To use these, add this declaration to the aspx page:

<%@ Register TagPrefix="MYPREFIX" Namespace="MyNamespace" Assembly="MYASSEMBLY" %>

Then add the control to the page like this:

Extended TextBox control:

<MYPREFIX:ExtendedTextBox ID="HomePhone" LabelText="Phone Number" CssClass="width_normal" LabelCssClass="width_normal" ValidatorCssClass="width_normal"
 Required="true" RequiredMessage="First name is required" DataType="Integer" runat="server" ></MYPREFIX:ExtendedTextBox>

If only the CssClass is specified, then the label and validator controls will inherit this class.

The Label and validator css classes can be individually specified using LabelCssClass and ValidatorCssClass.

You can add a RequiredMessage to set the validation message.  If this isn't specified, then the validation message will be 'LabelText is required'

LabelText isn't required - if it's missing then the 'required' asterisk will be placed next to the textbox

By default, client side validator script is generated (so you don't need to set 'ClientScript' to true).

DataType can be specified to validate a specific data type.  Supported values are Email and Integer

Extended RadioButtonList control:

<WVNZ:ExtendedRadioButtonList RepeatLayout="Flow" ID="WrittenContactPreference" LabelText="Preferred written contact preference"
                    LabelCssClass="boldLabel" runat="server" Required="false">

      <asp:ListItem>Email</asp:ListItem>

      <asp:ListItem>Home</asp:ListItem>

</WVNZ:ExtendedRadioButtonList>

For the controls to work, the following needs to be built into an assembly called 'MYASSEMBLY' that's referenced by the project where the control is being implemented:

```<code>using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyNamespace
{
public interface IExtendedControl
{
    string ID { get; set; }
    bool Required { get; set; }
    string CssClass { get; set; }
    Label lbl { get; set; }
    string LabelText { get; set; }
    string LabelCssClass { get; set; }
    RequiredFieldValidator rfv { get; set; }
    string RequiredMessage { get; set; }
    string ValidatorCssClass { get; set; }
    bool ClientScript { get; set; }
    ControlCollection Controls { get; }
}

public static class ExtendedControlExtensions
{
    public static void AddRequiredFieldValidator(this IExtendedControl control)
    {
        if (!control.RequiredMessage.IsNullOrEmpty())
        {
            control.rfv.ErrorMessage = control.RequiredMessage;
        }
        else
        {
            control.rfv.ErrorMessage = control.LabelText + " is required";
        }

        ConfigureAndAddValidator(control, control.rfv);
    }

    public static void ConfigureAndAddValidator(this IExtendedControl control, BaseValidator validator)
    {
        validator.ControlToValidate = control.ID;
        validator.Display = ValidatorDisplay.Dynamic;
        validator.CssClass = "validationMessage ";
        if (!control.ValidatorCssClass.IsNullOrEmpty())
        {
            validator.CssClass += control.ValidatorCssClass;
        }
        else validator.CssClass += control.CssClass;
        validator.EnableClientScript = control.ClientScript;
        control.Controls.Add(validator);
    }

    public static void AddLabel(this IExtendedControl control, string controlCssClass = "")
    {
        control.lbl = new Label();
        control.lbl.Text = control.LabelText;
        if (control.Required)
        {
            control.lbl.Text += " <span class=\"requiredFieldIndicator\"> *</span>";
        }

        control.lbl.ID = "lbl" + control.ID;
        //TODO: associate label with control - code below needs other fixes to work
        //lbl.AssociatedControlID = this.ID;

        string cssClassToUse;
        if (!control.LabelCssClass.IsNullOrEmpty()) cssClassToUse = control.LabelCssClass;
        else cssClassToUse = control.CssClass;

        if (control.LabelText.IsNullOrEmpty())
        {
            control.lbl.CssClass = cssClassToUse + " form_field_empty_label ";
        }
        else
        {
            control.lbl.CssClass = cssClassToUse + " form_field_label " + controlCssClass;
        }
    }
}

public class ExtendedTextBox : TextBox, IExtendedControl
{
    public string LabelText { get; set; }
    public string LabelCssClass { get; set; }
    public bool Required { get; set; }
    public string RequiredMessage { get; set; }
    public string DataType;
    public string DataInvalidMessage;
    public string ValidatorCssClass { get; set; }
    public bool ClientScript { get; set; }
    public Label lbl { get; set; }
    public RequiredFieldValidator rfv { get; set; }
    private CompareValidator cv;
    private RegularExpressionValidator rev;
    private bool IsRegExpValidator;

    protected override void OnInit(EventArgs e)
    {
        rfv = new RequiredFieldValidator();
        ClientScript = true;

        this.AddLabel();

        if (Required)
        {
            this.AddRequiredFieldValidator();
        }

        if (!DataType.IsNullOrEmpty())
        {
            switch (DataType)
            {
                case "Email":
                    IsRegExpValidator = true;
                    AddRegExValidator(DataType);
                    break;
                default:
                    AddCompareValidator(DataType);
                    break;
            }
        }
    }

    private void AddCompareValidator(string DataType)
    {
        cv = new CompareValidator();
        cv.Operator = ValidationCompareOperator.DataTypeCheck;

        switch (DataType)
        {
            case "Integer":
                cv.Type = ValidationDataType.Integer;
                cv.ErrorMessage = "Please enter a numeric value";
                break;
            default:
                break;
        }

        if (!this.DataInvalidMessage.IsNullOrEmpty())
        {
            cv.ErrorMessage = this.DataInvalidMessage;
        }

        this.ConfigureAndAddValidator(cv);
    }

    private void AddRegExValidator(string DataType)
    {
        // for regex explanation see http://www.codeproject.com/Articles/22777/Email-Address-Validation-Using-Regular-Expression
        const string MatchEmailPattern =
            @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
             + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
                        [0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
             + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
                        [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
             + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

        rev = new RegularExpressionValidator();

        switch (DataType)
        {
            case "Email":
                rev.ValidationExpression = MatchEmailPattern;
                rev.ErrorMessage = "Please enter a valid email address";
                break;
            default:
                break;
        }

        if (!this.DataInvalidMessage.IsNullOrEmpty())
        {
            rev.ErrorMessage = this.DataInvalidMessage;
        }

        this.ConfigureAndAddValidator(rev);
    }

    protected override void Render(HtmlTextWriter w)
    {
        lbl.RenderControl(w);
        base.Render(w);
        if (Required)
        {
            rfv.RenderControl(w);
        }
        if (!DataType.IsNullOrEmpty())
        {
            if (IsRegExpValidator)
                rev.RenderControl(w);
            else
                cv.RenderControl(w);
        }
    }
}

public class ExtendedRadioButtonList : RadioButtonList, IExtendedControl
{
    public string LabelText { get; set; }
    public string LabelCssClass { get; set; }
    public bool Required { get; set; }
    public string RequiredMessage { get; set; }
    public string ValidatorCssClass { get; set; }
    public bool ClientScript { get; set; }
    public Label lbl { get; set; }
    public RequiredFieldValidator rfv { get; set; }

    protected override void OnInit(EventArgs e)
    {
        rfv = new RequiredFieldValidator();
        ClientScript = true;

        this.CssClass = "radioButtonList";

        this.AddLabel(this.CssClass);

        if (Required)
        {
            this.AddRequiredFieldValidator();
        }
    }

    protected override void Render(HtmlTextWriter w)
    {
        lbl.RenderControl(w);
        base.Render(w);
        if (Required)
        {
            rfv.RenderControl(w);
        }
    }
}
}
</code>```

The form can then be laid out using the following markup:

```<code><fieldset id="PersonalDetails" >
    <legend>Personal Details</legend>
    <div class="form_row">
        <p>
            <strong>Name</strong></p>
        <div class="form_field">
            <MYPREFIX:ExtendedTextBox ID="PreferredTitle" LabelText="Title" CssClass="width_x-small"
                LabelCssClass="width_x-small" ValidatorCssClass="width_x-small" runat="server"
                Required="false">
            </MYPREFIX:ExtendedTextBox>
        </div>
        <div class="form_field">
            <MYPREFIX:ExtendedTextBox ID="FirstName" LabelText="First" CssClass="required width_small"
                ValidatorCssClass="width_small" runat="server" Required="true" RequiredMessage="First name is required">
            </MYPREFIX:ExtendedTextBox>
        </div>
        <div class="form_field">
            <MYPREFIX:ExtendedTextBox ID="LastName" LabelText="Last" CssClass="width_small" runat="server"
                Required="true" RequiredMessage="Last name is required">
            </MYPREFIX:ExtendedTextBox>
        </div>
    </div>
</fieldset>
</code>```

And when the following stylesheet is added to the page it should work nicely.  I'm using this in conjunction with the JQuery Datepicker so if this is used, styling will be done for the datepicker widget

```<code>fieldset legend
{
    font-size: 20px;
    padding: 16px 0px;
}

.form_row
{
    margin-bottom: 10px;
}

.form_field
{
    display: inline-block;
    vertical-align: top;
}

.form_field input, textarea
{
    font-weight: normal !important;
    display: block;
    margin-bottom: 2px;
}

.form_field .radioButtonList
{
    display: block;
}

.form_field .radioButtonList input
{
    display: inline;
    vertical-align: middle;
    margin-bottom: 5px;
}

.form_field .radioButtonList label
{
    display: inline;
    vertical-align: middle;
    margin-left: 5px;
}

.form_field .radioButtonList .validationMessage
{
    float: right;
    clear: both;
    vertical-align: middle;
    margin-left: 5px;
}

.form_field.datepicker input
{
    display: inline;
    float: left;
}

.form_field .datepicker
{
    display: inline;
    float: left;
    vertical-align: middle;
}

.form_field .ui-datepicker-trigger
{
    display: inline;
    float: left;
    margin-left: 5px;
    vertical-align: middle;
}

.form_field.datepicker .validationMessage
{
    clear: both;
}

.ui-datepicker .ui-datepicker-title select
{
    font-size: 0.9em;
    min-width: 0;
}

thead th.ui-datepicker-week-end:first-child
{
    font-size: 1em;
}

table.ui-datepicker-calendar tr:first-child td
{
    font-size: 1em;
}

.form_field .form_field_label
{
    color: #777777;
    display: block;
    font-size: 11px;
    font-weight: normal;
    line-height: inherit;
    float: none;
}

.form_field_label.radioButtonList
{
    margin-bottom: 8px;
}

.form_field_empty_label .requiredFieldIndicator
{
    display: inline;
    font-size: 11px;
    vertical-align: middle;
}

.form_field label
{
    color: #777777;
    display: block;
    font-size: 11px;
    float: none;
}

.boldLabel
{
    font-size: 12px;
    font-weight: bold;
    color: #333333;
    margin-top: 8px;
    margin-bottom: 12px;
}

.requiredFieldIndicator
{
    color: Red;
}

/* general widths */
.width_x-small
{
    width: 25px !important;
}
.width_small
{
    width: 75px !important;
}
.width_normal
{
    width: 150px !important;
}
.width_large
{
    width: 200px !important;
}
.width_x-large
{
    width: 275px !important;
}
.width_xx-large
{
    width: 350px !important;
}
.validationMessage
{
    color: Red;
    font-size: 11px;
    float: left;
}

#body-copy input.ui-formwizard-button
{
    cursor: pointer;
    font-size: 1.5em;
}
</code>```

I'm intending to put fuller details of this solution onto a blog or into a code project somewhere when I get time so that it can be developed open source into a full set of controls.  If anyone wants to do this in the meantime, please feel free to do so, and please post a link here to help out other developers.

Cheers

Body:
Thanks for the replies.  Fuex - you put me on the right track, here's the final code which includes an a extended TextBox control and extended RadioButtonList control.

To use these, add this declaration to the aspx page:

<%@ Register TagPrefix="MYPREFIX" Namespace="MyNamespace" Assembly="MYASSEMBLY" %>

Then add the control to the page like this:

Extended TextBox control:

<MYPREFIX:ExtendedTextBox ID="HomePhone" LabelText="Phone Number" CssClass="width_normal" LabelCssClass="width_normal" ValidatorCssClass="width_normal"
 Required="true" RequiredMessage="First name is required" DataType="Integer" runat="server" ></MYPREFIX:ExtendedTextBox>

If only the CssClass is specified, then the label and validator controls will inherit this class.

The Label and validator css classes can be individually specified using LabelCssClass and ValidatorCssClass.

You can add a RequiredMessage to set the validation message.  If this isn't specified, then the validation message will be 'LabelText is required'

LabelText isn't required - if it's missing then the 'required' asterisk will be placed next to the textbox

By default, client side validator script is generated (so you don't need to set 'ClientScript' to true).

DataType can be specified to validate a specific data type.  Supported values are Email and Integer

Extended RadioButtonList control:

<WVNZ:ExtendedRadioButtonList RepeatLayout="Flow" ID="WrittenContactPreference" LabelText="Preferred written contact preference"
                    LabelCssClass="boldLabel" runat="server" Required="false">

      <asp:ListItem>Email</asp:ListItem>

      <asp:ListItem>Home</asp:ListItem>

</WVNZ:ExtendedRadioButtonList>

For the controls to work, the following needs to be built into an assembly called 'MYASSEMBLY' that's referenced by the project where the control is being implemented:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyNamespace
{
public interface IExtendedControl
{
    string ID { get; set; }
    bool Required { get; set; }
    string CssClass { get; set; }
    Label lbl { get; set; }
    string LabelText { get; set; }
    string LabelCssClass { get; set; }
    RequiredFieldValidator rfv { get; set; }
    string RequiredMessage { get; set; }
    string ValidatorCssClass { get; set; }
    bool ClientScript { get; set; }
    ControlCollection Controls { get; }
}

public static class ExtendedControlExtensions
{
    public static void AddRequiredFieldValidator(this IExtendedControl control)
    {
        if (!control.RequiredMessage.IsNullOrEmpty())
        {
            control.rfv.ErrorMessage = control.RequiredMessage;
        }
        else
        {
            control.rfv.ErrorMessage = control.LabelText + " is required";
        }

        ConfigureAndAddValidator(control, control.rfv);
    }

    public static void ConfigureAndAddValidator(this IExtendedControl control, BaseValidator validator)
    {
        validator.ControlToValidate = control.ID;
        validator.Display = ValidatorDisplay.Dynamic;
        validator.CssClass = "validationMessage ";
        if (!control.ValidatorCssClass.IsNullOrEmpty())
        {
            validator.CssClass += control.ValidatorCssClass;
        }
        else validator.CssClass += control.CssClass;
        validator.EnableClientScript = control.ClientScript;
        control.Controls.Add(validator);
    }

    public static void AddLabel(this IExtendedControl control, string controlCssClass = "")
    {
        control.lbl = new Label();
        control.lbl.Text = control.LabelText;
        if (control.Required)
        {
            control.lbl.Text += " <span class=\"requiredFieldIndicator\"> *</span>";
        }

        control.lbl.ID = "lbl" + control.ID;
        //TODO: associate label with control - code below needs other fixes to work
        //lbl.AssociatedControlID = this.ID;

        string cssClassToUse;
        if (!control.LabelCssClass.IsNullOrEmpty()) cssClassToUse = control.LabelCssClass;
        else cssClassToUse = control.CssClass;

        if (control.LabelText.IsNullOrEmpty())
        {
            control.lbl.CssClass = cssClassToUse + " form_field_empty_label ";
        }
        else
        {
            control.lbl.CssClass = cssClassToUse + " form_field_label " + controlCssClass;
        }
    }
}

public class ExtendedTextBox : TextBox, IExtendedControl
{
    public string LabelText { get; set; }
    public string LabelCssClass { get; set; }
    public bool Required { get; set; }
    public string RequiredMessage { get; set; }
    public string DataType;
    public string DataInvalidMessage;
    public string ValidatorCssClass { get; set; }
    public bool ClientScript { get; set; }
    public Label lbl { get; set; }
    public RequiredFieldValidator rfv { get; set; }
    private CompareValidator cv;
    private RegularExpressionValidator rev;
    private bool IsRegExpValidator;

    protected override void OnInit(EventArgs e)
    {
        rfv = new RequiredFieldValidator();
        ClientScript = true;

        this.AddLabel();

        if (Required)
        {
            this.AddRequiredFieldValidator();
        }

        if (!DataType.IsNullOrEmpty())
        {
            switch (DataType)
            {
                case "Email":
                    IsRegExpValidator = true;
                    AddRegExValidator(DataType);
                    break;
                default:
                    AddCompareValidator(DataType);
                    break;
            }
        }
    }

    private void AddCompareValidator(string DataType)
    {
        cv = new CompareValidator();
        cv.Operator = ValidationCompareOperator.DataTypeCheck;

        switch (DataType)
        {
            case "Integer":
                cv.Type = ValidationDataType.Integer;
                cv.ErrorMessage = "Please enter a numeric value";
                break;
            default:
                break;
        }

        if (!this.DataInvalidMessage.IsNullOrEmpty())
        {
            cv.ErrorMessage = this.DataInvalidMessage;
        }

        this.ConfigureAndAddValidator(cv);
    }

    private void AddRegExValidator(string DataType)
    {
        // for regex explanation see http://www.codeproject.com/Articles/22777/Email-Address-Validation-Using-Regular-Expression
        const string MatchEmailPattern =
            @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
             + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
                        [0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
             + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
                        [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
             + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

        rev = new RegularExpressionValidator();

        switch (DataType)
        {
            case "Email":
                rev.ValidationExpression = MatchEmailPattern;
                rev.ErrorMessage = "Please enter a valid email address";
                break;
            default:
                break;
        }

        if (!this.DataInvalidMessage.IsNullOrEmpty())
        {
            rev.ErrorMessage = this.DataInvalidMessage;
        }

        this.ConfigureAndAddValidator(rev);
    }

    protected override void Render(HtmlTextWriter w)
    {
        lbl.RenderControl(w);
        base.Render(w);
        if (Required)
        {
            rfv.RenderControl(w);
        }
        if (!DataType.IsNullOrEmpty())
        {
            if (IsRegExpValidator)
                rev.RenderControl(w);
            else
                cv.RenderControl(w);
        }
    }
}

public class ExtendedRadioButtonList : RadioButtonList, IExtendedControl
{
    public string LabelText { get; set; }
    public string LabelCssClass { get; set; }
    public bool Required { get; set; }
    public string RequiredMessage { get; set; }
    public string ValidatorCssClass { get; set; }
    public bool ClientScript { get; set; }
    public Label lbl { get; set; }
    public RequiredFieldValidator rfv { get; set; }

    protected override void OnInit(EventArgs e)
    {
        rfv = new RequiredFieldValidator();
        ClientScript = true;

        this.CssClass = "radioButtonList";

        this.AddLabel(this.CssClass);

        if (Required)
        {
            this.AddRequiredFieldValidator();
        }
    }

    protected override void Render(HtmlTextWriter w)
    {
        lbl.RenderControl(w);
        base.Render(w);
        if (Required)
        {
            rfv.RenderControl(w);
        }
    }
}
}

The form can then be laid out using the following markup:

<fieldset id="PersonalDetails" >
    <legend>Personal Details</legend>
    <div class="form_row">
        <p>
            <strong>Name</strong></p>
        <div class="form_field">
            <MYPREFIX:ExtendedTextBox ID="PreferredTitle" LabelText="Title" CssClass="width_x-small"
                LabelCssClass="width_x-small" ValidatorCssClass="width_x-small" runat="server"
                Required="false">
            </MYPREFIX:ExtendedTextBox>
        </div>
        <div class="form_field">
            <MYPREFIX:ExtendedTextBox ID="FirstName" LabelText="First" CssClass="required width_small"
                ValidatorCssClass="width_small" runat="server" Required="true" RequiredMessage="First name is required">
            </MYPREFIX:ExtendedTextBox>
        </div>
        <div class="form_field">
            <MYPREFIX:ExtendedTextBox ID="LastName" LabelText="Last" CssClass="width_small" runat="server"
                Required="true" RequiredMessage="Last name is required">
            </MYPREFIX:ExtendedTextBox>
        </div>
    </div>
</fieldset>

And when the following stylesheet is added to the page it should work nicely.  I'm using this in conjunction with the JQuery Datepicker so if this is used, styling will be done for the datepicker widget

fieldset legend
{
    font-size: 20px;
    padding: 16px 0px;
}

.form_row
{
    margin-bottom: 10px;
}

.form_field
{
    display: inline-block;
    vertical-align: top;
}

.form_field input, textarea
{
    font-weight: normal !important;
    display: block;
    margin-bottom: 2px;
}

.form_field .radioButtonList
{
    display: block;
}

.form_field .radioButtonList input
{
    display: inline;
    vertical-align: middle;
    margin-bottom: 5px;
}

.form_field .radioButtonList label
{
    display: inline;
    vertical-align: middle;
    margin-left: 5px;
}

.form_field .radioButtonList .validationMessage
{
    float: right;
    clear: both;
    vertical-align: middle;
    margin-left: 5px;
}

.form_field.datepicker input
{
    display: inline;
    float: left;
}

.form_field .datepicker
{
    display: inline;
    float: left;
    vertical-align: middle;
}

.form_field .ui-datepicker-trigger
{
    display: inline;
    float: left;
    margin-left: 5px;
    vertical-align: middle;
}

.form_field.datepicker .validationMessage
{
    clear: both;
}

.ui-datepicker .ui-datepicker-title select
{
    font-size: 0.9em;
    min-width: 0;
}

thead th.ui-datepicker-week-end:first-child
{
    font-size: 1em;
}

table.ui-datepicker-calendar tr:first-child td
{
    font-size: 1em;
}

.form_field .form_field_label
{
    color: #777777;
    display: block;
    font-size: 11px;
    font-weight: normal;
    line-height: inherit;
    float: none;
}

.form_field_label.radioButtonList
{
    margin-bottom: 8px;
}

.form_field_empty_label .requiredFieldIndicator
{
    display: inline;
    font-size: 11px;
    vertical-align: middle;
}

.form_field label
{
    color: #777777;
    display: block;
    font-size: 11px;
    float: none;
}

.boldLabel
{
    font-size: 12px;
    font-weight: bold;
    color: #333333;
    margin-top: 8px;
    margin-bottom: 12px;
}

.requiredFieldIndicator
{
    color: Red;
}

/* general widths */
.width_x-small
{
    width: 25px !important;
}
.width_small
{
    width: 75px !important;
}
.width_normal
{
    width: 150px !important;
}
.width_large
{
    width: 200px !important;
}
.width_x-large
{
    width: 275px !important;
}
.width_xx-large
{
    width: 350px !important;
}
.validationMessage
{
    color: Red;
    font-size: 11px;
    float: left;
}

#body-copy input.ui-formwizard-button
{
    cursor: pointer;
    font-size: 1.5em;
}

I'm intending to put fuller details of this solution onto a blog or into a code project somewhere when I get time so that it can be developed open source into a full set of controls.  If anyone wants to do this in the meantime, please feel free to do so, and please post a link here to help out other developers.

Cheers


答: At least in the United States, my understanding of the law is that if you weren't specifically directed to write this program and signed no contract, at best your employer has something akin to a "shop right". Per 17 USC 201, it hinges on whether the work is considered a "work made for hire".</p>


答:
The answer is no, they can't give away your intellectual property.

As for your dilemma, perhaps consider licensing your code. As a programmer myself, I know it would suck to just have my work stolen without recognition. If you don't want to charge them for it but simply wanted to maintain your authorship, perhaps consider an open source license such as Creative Commons Attribute-ShareAlike which would allow them to use the code for commercial purposes, but they'd have to attribute you and distribute any changes to the code under the same license. This won't stop them from simply plagiarising your code, but they should at least have a guilty conscience if they chose to do so.


问:
How can I send a signal to a program via external hardware
I am trying to find a piece of hardware that will signal a program to start a timer when it is moving and stop when it stops. The hardware can just be a ball that moves and is connected to the computer through USB, I was thinking of something similar to the way a mouse would work. For the programing I would like to use c# or possibly ActionScript with adobe air. I am a web developer and have not had any experience with hardware or drivers and would appreciate any ideas on where to start. Maybe there is some piece of simple hardware out there that I can use to send signals to the computer or some literature of articles for beginners that you can point me to. Thanks in advance</p>

答:
For USB I/O that you can interface with .NET, check out Phidgets.  For instance, there are accelerometer motion sensors that connect directly over USB.  They have documentation about their .NET SDK on their site.  I've used it with success.

You could also just use a mouse, right?  :)

I also thought this project on kickstarter is similar to what you're describing, and wouldn't require any coding.

If you wanted to go wireless, consider buying a Wiimote and using the wiimotelib library written in C#.  You'll need a bluetooth connection on the PC.

If you have an Android phone, you could access the accelerometer and use that for motion detection.  You could use it in a tethered only mode... not sure how to interface it directly over the USB cable.  Alternatively it could be wireless over a WiFi connection.


答:
You need to step back from the legality question. Why did you do an unpaid internship? You are being compensated in two ways:

Work Experience

Job Recommendations

So talk to your boss, make sure he knows you think you went the extra mile for this project, and ask him if he would be willing to provide strong recommendations when you go looking for a job. If you try to bring a lawyer into this, what kind of recommendation do you think you'll get?

Sure, you made no money on this code, but you already went in with the expectation of no pay! The entire point is to get a good paying job. Whatever you get by haggling over this one project is not going to compare to the lifetime gain you stand to get if he can help you jump start a career.


答:
(assuming US law)

It seems fairly clear that this is not a "work made for hire" under 17 USC 101, because that requires the work to have been made by an employee within the scope of their employment. For this to be so, the person necessarily has to be an employee.

Interns that are employees MUST be paid minimum wage under the Fair Labor Standards Act, and so we may infer from his internship being unpaid that he was not an employee.

Thus, under 17 USC 201 the copyrighted vested in him, the author, and there it remains.

However, that doesn't necessarily mean he's free to do anything he wants with the code. It is possible that he was exposed to trade secrets of theirs and that he embodied those in the code. If that's the case, they may have some recourse under trade secret law to keep him from disclosing the code to third parties.


答:
If you're serious then consult a lawyer. That will cost you $$.

Or just give them the code as-is, don't sign or agree to anything more, then get very busy with other projects and activities.

They will want you to answer questions, how to compile, configure, make changes, documentation etc. Respond to their emails within a few days and politely, tell them it is in the code, but remind them how busy you are with your other projects/life.

If they really want help from you then turn it into a paid gig.

Either for you or for the startup, it will take a lot of time and $ to convert a very useful in-house tool to a sellable product, and even more time and $ to actually sell it. It is a lot harder and more expensive than it looks.


问:
What makes for a good architect/manager/lead developer?
I am the Lead Developer for a small software company. Over the past two years, my team has grown from one developer (me) to a group of about nine people. Most of us are very capable, senior engineers (20+ years of experience building software per person), so very little hand-holding is generally necessary. We use Scrum to manage our efforts, and we usually get a lot done quickly with minimal written requirements.

As the team has grown, I've reached the point where it is difficult for me to retain technical oversight over the entire project while also writing significant amounts of new code myself, so it is time for me to adjust my role. How can I make myself most useful to the team when I'm no longer spending most of my time developing?

My goal is to allow my group to grow even further (i.e. increase Scrum velocity) by adding more developers, so I don't want to simply become the "architecture police" who imposes my will on the team. In other words, I want to be the guy who helps things work better/smoother, rather than be the guy who slows things by down by adding an unnecessary layer of bureaucracy. Still, one of our main risks is that things will spin out of control if we add more people without having enough structure to keep us all on the same page.

What is the best way to achieve my goal?

答:
If you were on a team like this, what would you want your boss to do with his time?

Remove impediments to progress.

Mediate disputes between team members.

Interact with business people so we don't have to.

Keep us informed of that higher level business/project stuff so we don't feel isolated.

Keep us honest, especially if/when a bad apple gets into the team.

Be an advocate for the team to other departments.

Be the unified voice of push-back against unreasonable business requests.

Facilitate communication amongst the team.

There's probably a bunch I'm forgetting, but that's the core of it. Don't implement process, handle some of that overhead/inefficiency that naturally develops as the team size increases.


答:
I'd have no problems with a team lead that was capable of balancing both managerial and technical duties, but it is tough to find people that do well managing that balance.

If I had to choose between the two extremes from a team lead on a growing team...it's a really tough choice but ultimately I think I'd want the team lead to become more of a manager. On a sizable team you'd hope there would be other candidates to step into the senior developer role that could nurture the team's newer members and still do some heavy lifting in development.

But on a growing team you'd definitely want a good manager too. In fact, having a good person with the management title is important because you want him/her to have enough power to carry out good decisions. A good manager has a big influence over a team's happiness and for exactly the reasons you are indicating; by helping to keep them productive - and good for you for thinking like you are. There are a lot of managers that don't give a rat's ass.

I'd recommend a few other posts here at Programmers. Although they are geared more to a team lead than an official managerial role, they may help:

Making the move to Team Leading

How do I succeed as a Lead Developer?

How to earn team members respect as team lead?

Title: What makes for a good architect/manager/lead developer?

Body:
I am the Lead Developer for a small software company. Over the past two years, my team has grown from one developer (me) to a group of about nine people. Most of us are very capable, senior engineers (20+ years of experience building software per person), so very little hand-holding is generally necessary. We use Scrum to manage our efforts, and we usually get a lot done quickly with minimal written requirements.

As the team has grown, I've reached the point where it is difficult for me to retain technical oversight over the entire project while also writing significant amounts of new code myself, so it is time for me to adjust my role. How can I make myself most useful to the team when I'm no longer spending most of my time developing?

My goal is to allow my group to grow even further (i.e. increase Scrum velocity) by adding more developers, so I don't want to simply become the "architecture police" who imposes my will on the team. In other words, I want to be the guy who helps things work better/smoother, rather than be the guy who slows things by down by adding an unnecessary layer of bureaucracy. Still, one of our main risks is that things will spin out of control if we add more people without having enough structure to keep us all on the same page.

What is the best way to achieve my goal?


答:
I think it is a balance of these traits:

Technical skill: You don't want someone leading that cannot assess the quality of the work he/she is directing.

Self-driven: Can define goals and not be reactive.

Knows how to capitalize on conflict: Conflict triggers conversations

Auto-didactic: It is not important that he/she knows everything, but knows how to learn.

Good attitude and energy: You want someone that motivates and makes everybody's work easier, not a diva that barks orders.

Experience with failure: Possibly the most important one. I've seen very young leaders who might have no problem with all the previous, but at the first sign of failure they freeze or avoid responsibility. Seniority has nothing to do with age, but the right amount of the right experience, and failure is definitely something to consider.

OTOH, the interview is an important part of getting the right person, I'd recommend you to ask the following questions in the interview:

"Tell me a project where you experienced failure, how you managed it and what you learned from it"

"Tell me about one time where you broke the rules to get things done"

Apply the Fizz Buzz test, with any slight twist you can think of.

The FizzBuzz test is absolutely a must, being right or wrong it is not as important as:

The time it takes him/her to answer: 15 min average, 30 min borderline ok, >30 min NOT OK

If he/she is able to debug his/her own code: I once had a guy with 15 years of experience apply for a senior position... he took 40 minutes to get the test done... in pseudocode... got it wrong and could not find out why. I had another case where another guy, spent about 5 minutes justifying himself and couldn't accept he was wrong at all.


问:
I want to create an open data format... but I don't really know what that is
I have found a need for a standardization for storage and recording of data relating to diabetes information (I don't think there's any, but I may have missed it).

To that end I made this github project because I want to create one.. but I don't really know how to go about it, or even for sure what I want to create is called.

Do I need to pick a language (xml, json) or a database type (mongo, sqlite, mysql), or how 'unspecific' is possible with something like this.

Is a data format as I describe here a thing? Are there other names for what I want to try to do? It's a bit of a strange task to accomplish compared to what I'm used to.

答: Don't use XML or Mr. Atwood will find and destroy you. All kidding aside, JSON could be used, and can be loaded, manipulated, and saved out from a variety of tech these days, such as with Javascript (JQuery) on web pages. JQuery can load a file hosted on a remote URL, the result from a web service API URI, parse it into Javascript objects, save it back out to disk or send results off to other places. Ubermensch mentions above that MongoDB can load from JSON, but you could just as easily create your own web service (REST or SOAP) that takes JSON via HTTP POST and then stores it in any database system you want. He also mentions that you can create a data schema, but I'm not sure if there exists something as easy to validate with as an XML Schema Definition (XSD) and the various more robust tools around that older tech. So one advantage to using XML would be to create an XSD and publish it, and various editing tools could load that and understand how to give you "code-completion" (Visual Studio's IntelliSense, for example) and in-line validation. Another technology to consider to making accessing the data standardized would be OData, so if you did have a web service in front of your data warehouse you could expose it to people for querying in a secure fashion.</p>


问:
How to manage/organise when you have to multi-task on multiple 1 man projects?
We are a team of developers working on multiple small projects - a developer could have 3 or more 1 man projects to work on and keep moving. It can feel like your time is pretty fragmented & interrupted moving between project to project. Sometimes frustrating, stressful & overwhelming. In an ideal world it wouldn't be this way but it appears to be very common. When you are in a setup where it can't be avoided, how do you make the best of it?

I'm looking for ideas/tips/methods that will help increase productivity & reduce stress specifically in multi-tasking environments. DOs and DON'Ts etc. What boundaries, limits should be in place? Which development methodologies will & won't work? What do you know that does WORK?

Is there any good way to organise this kind of environment to be maximum productive?

答:
My initial response is that if you have a team, why are you working like you don't?

Certainly, there may be a reason, but I am not sure it is stated.

Limiting Factors

My suggestion is that you organize work to field as much product as early as possible and with the greatest possible profit margin.  How you do this may depend on your business model and a variety of factors, including some that limit what you can do.

Responsiveness: Can we do one project until it is done?  Or do we need to spend time with stakeholders for each project in a way that shows we respond to their needs?

Focus: We can only accelerate to our maximum velocity on a task if we have blocks of time to focus on the work.

Communication/Consultation: Do we need to communicate early and often, perhaps consult on decisions, thereby introducing delays into the work?  What is the minimum we must do to use prototypes and round robin switching between projects to accomplish our needs in this category?

Division of labor: Does one person do several kinds of work?  Could we divide the projects so repetitive work of the same kind is done by someone who builds expertise that much faster because they do more of it?

Capital/cash flow: Do we get paid at the end, as we reach milestones, or for time and materials?  Does working multiple projects in parallel give us multiple payments or just delay projects that could complete in series?

Competition: Is the market for our product such that early entry would let us sell more because we would have fewer competitors?

Adoption: If we get there early, is the market too immature for us to have strong sales until the market starts to adopt our product?  Is there an advantage to wait for someone else to be the pioneer?

Revenue stream: Do we get paid once on completion, or does completing the project permit the sale of a product in constant or growing quantities?  Are there maintenance or subscription fees our customer will pay to us once the product is fielded?

A Few Hypothetical Scenarios

If you charge time and materials, but only get paid at the end, your limiting factor is project duration.  If you have four projects, if you assign everyone one each job doing the jobs in sequence from shortest to longest.  You have the profit from the first job to reduce the borrowed resources for the second job, or to hire more help to finish the second job faster.

If you make a product that once completed creates a market with constant or increasing sales every month, you have a compounding revenue increase with each project completed.  If you take a strictly round robin approach, this will happen later, rather than sooner.

If you prioritize your longest duration job, every other job will wait and the small jobs will start to have the longest duration, which is a particular problem in the eyes of those customers.

If you are selling something for which being first to market weights revenue in your favor, you can afford to sacrifice something to be early.

If you work only your highest priority, you may have one happy customer and the remaining customers unhappy or going elsewhere.

A Naive Example

Many years ago, I worked at a company where it was considered efficient and empowering to have each of the four software developers work as a lead on their own project which typically took nine to twelve months each.  This went on a couple years, we added a few more people organizing in the same way.  Then, we had a bigger project and made a four person team instead.  With the team we took on a much larger project, and when it released about 12 months later, we had the best year in the company's history.

Shortly afterward, a colleague and I had a conversation about the idea that our future projects might make more money if we stopped doing the one project per person per year.  Here is a sketch:

```<code>Method 1: Project per developer
Four developers, four projects of 12 months duration, that sell 500K/quarter.

                           Project 1    Project 2   Project 3   Project 4   Total
Q1:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q2:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q3:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q4:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q5:
Labor (man months):        0            0           0           0           0
Net Income:                500K         500K        500K        500K        2000K

Y1 Income: $0
Total Income for 15 months: $2000K

Method 2: Four developers working as a team.
Four developers, four projects of 12 months duration, that sell 500K/quarter.

                           Project 1    Project 2   Project 3   Project 4   Total
Q1:
Labor (man months):        12           0           0           0           12
Net Income:                0            0           0           0           0

Q2:
Labor (man months):        0            12          0           0           12
Net Income:                500K         0           0           0           500K

Q3:
Labor (man months):        0            0           12          0           12
Net Income:                500K         500K        0           0           1000

Q4:
Labor (man months):        3            3           3           3           12
Net Income:                500K         500K        500K        0           1500K

Q5:
Labor (man months):        0            0           0           0           0
Net Income:                500K         500K        500K        500K        2000K

Y1 Income: $3000
Total Income for 15 months: $5000K
</code>```

This example is simpler than any real work environment would be.  But hopefully it illustrates that if we are multitasking, we are delaying and reducing our rewards as compared to single focus and teamwork.

Body:
My initial response is that if you have a team, why are you working like you don't?

Certainly, there may be a reason, but I am not sure it is stated.

Limiting Factors

My suggestion is that you organize work to field as much product as early as possible and with the greatest possible profit margin.  How you do this may depend on your business model and a variety of factors, including some that limit what you can do.

Responsiveness: Can we do one project until it is done?  Or do we need to spend time with stakeholders for each project in a way that shows we respond to their needs?

Focus: We can only accelerate to our maximum velocity on a task if we have blocks of time to focus on the work.

Communication/Consultation: Do we need to communicate early and often, perhaps consult on decisions, thereby introducing delays into the work?  What is the minimum we must do to use prototypes and round robin switching between projects to accomplish our needs in this category?

Division of labor: Does one person do several kinds of work?  Could we divide the projects so repetitive work of the same kind is done by someone who builds expertise that much faster because they do more of it?

Capital/cash flow: Do we get paid at the end, as we reach milestones, or for time and materials?  Does working multiple projects in parallel give us multiple payments or just delay projects that could complete in series?

Competition: Is the market for our product such that early entry would let us sell more because we would have fewer competitors?

Adoption: If we get there early, is the market too immature for us to have strong sales until the market starts to adopt our product?  Is there an advantage to wait for someone else to be the pioneer?

Revenue stream: Do we get paid once on completion, or does completing the project permit the sale of a product in constant or growing quantities?  Are there maintenance or subscription fees our customer will pay to us once the product is fielded?

A Few Hypothetical Scenarios

If you charge time and materials, but only get paid at the end, your limiting factor is project duration.  If you have four projects, if you assign everyone one each job doing the jobs in sequence from shortest to longest.  You have the profit from the first job to reduce the borrowed resources for the second job, or to hire more help to finish the second job faster.

If you make a product that once completed creates a market with constant or increasing sales every month, you have a compounding revenue increase with each project completed.  If you take a strictly round robin approach, this will happen later, rather than sooner.

If you prioritize your longest duration job, every other job will wait and the small jobs will start to have the longest duration, which is a particular problem in the eyes of those customers.

If you are selling something for which being first to market weights revenue in your favor, you can afford to sacrifice something to be early.

If you work only your highest priority, you may have one happy customer and the remaining customers unhappy or going elsewhere.

A Naive Example

Many years ago, I worked at a company where it was considered efficient and empowering to have each of the four software developers work as a lead on their own project which typically took nine to twelve months each.  This went on a couple years, we added a few more people organizing in the same way.  Then, we had a bigger project and made a four person team instead.  With the team we took on a much larger project, and when it released about 12 months later, we had the best year in the company's history.

Shortly afterward, a colleague and I had a conversation about the idea that our future projects might make more money if we stopped doing the one project per person per year.  Here is a sketch:

Method 1: Project per developer
Four developers, four projects of 12 months duration, that sell 500K/quarter.

                           Project 1    Project 2   Project 3   Project 4   Total
Q1:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q2:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q3:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q4:
Labor (man months):        3            3           3           3           12
Net Income:                0            0           0           0           0

Q5:
Labor (man months):        0            0           0           0           0
Net Income:                500K         500K        500K        500K        2000K

Y1 Income: $0
Total Income for 15 months: $2000K

Method 2: Four developers working as a team.
Four developers, four projects of 12 months duration, that sell 500K/quarter.

                           Project 1    Project 2   Project 3   Project 4   Total
Q1:
Labor (man months):        12           0           0           0           12
Net Income:                0            0           0           0           0

Q2:
Labor (man months):        0            12          0           0           12
Net Income:                500K         0           0           0           500K

Q3:
Labor (man months):        0            0           12          0           12
Net Income:                500K         500K        0           0           1000

Q4:
Labor (man months):        3            3           3           3           12
Net Income:                500K         500K        500K        0           1500K

Q5:
Labor (man months):        0            0           0           0           0
Net Income:                500K         500K        500K        500K        2000K

Y1 Income: $3000
Total Income for 15 months: $5000K

This example is simpler than any real work environment would be.  But hopefully it illustrates that if we are multitasking, we are delaying and reducing our rewards as compared to single focus and teamwork.


答:
Have you found a need for a standardized format, or just a format?

The need for a standardized format really only arises when you want to make data available to multiple clients, and want to enable other providers to provide data as well. In that case, you need to discuss this with all the interested organizations and mutually come up with a good, all-covering data specification.

Any data format sufficiently specified can be called a 'standard'. However, it's only when it becomes widely adopted that it is truly a standard.

Anyway, the data specification will need to be unambiguous, easy to implement, robust, possibly versioned, and probably more.

Then you need to lobby to have major organizations or lots of people use your format, forcing the rest of the world to also use the format.

Congratulations, you've introduced a standard!

Obligatory:

http://xkcd.com/927/

Title: I want to create an open data format... but I don't really know what that is

Body:
I have found a need for a standardization for storage and recording of data relating to diabetes information (I don't think there's any, but I may have missed it).

To that end I made this github project because I want to create one.. but I don't really know how to go about it, or even for sure what I want to create is called.

Do I need to pick a language (xml, json) or a database type (mongo, sqlite, mysql), or how 'unspecific' is possible with something like this.

Is a data format as I describe here a thing? Are there other names for what I want to try to do? It's a bit of a strange task to accomplish compared to what I'm used to.


问:
How can I multiprocess my program?
I wrote a program which scrape internet sites. It is pretty straigtforward because it process link one by one.

With the limiting factor of the internet speed, the process is rather slow.

I wonder, how can I make it multiprocess? The modules of python is confusing. I don't know the difference between subprocess and multiprocess. I've heard that multiprocessing is difficult and ineffective because of the GIL since python 2.x. I am using Python 3.2, so I wonder if things have been improved.

答:
Many of the suggestions made are for python 2.x.

I found that python 3.x provide a easy to do multiprocess, that is the concurrent.futures module

The following snippet demonstrate the way to do it easily:

```<code>import concurrent.futures
import urllib.request

URLS = ['http://www.foxnews.com/',
        'http://www.cnn.com/',
        'http://europe.wsj.com/',
        'http://www.bbc.co.uk/',
        'http://some-made-up-domain.com/']

def load_url(url, timeout):
    return urllib.request.urlopen(url, timeout=timeout).read()

with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
    future_to_url = dict((executor.submit(load_url, url, 60), url)
                         for url in URLS)

    for future in concurrent.futures.as_completed(future_to_url):
        url = future_to_url[future]
        if future.exception() is not None:
            print('%r generated an exception: %s' % (url,
                                                     future.exception()))
        else:
            print('%r page is %d bytes' % (url, len(future.result())))
</code>```

Title: How can I multiprocess my program?

Body:
Many of the suggestions made are for python 2.x.

I found that python 3.x provide a easy to do multiprocess, that is the concurrent.futures module

The following snippet demonstrate the way to do it easily:

import concurrent.futures
import urllib.request

URLS = ['http://www.foxnews.com/',
        'http://www.cnn.com/',
        'http://europe.wsj.com/',
        'http://www.bbc.co.uk/',
        'http://some-made-up-domain.com/']

def load_url(url, timeout):
    return urllib.request.urlopen(url, timeout=timeout).read()

with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
    future_to_url = dict((executor.submit(load_url, url, 60), url)
                         for url in URLS)

    for future in concurrent.futures.as_completed(future_to_url):
        url = future_to_url[future]
        if future.exception() is not None:
            print('%r generated an exception: %s' % (url,
                                                     future.exception()))
        else:
            print('%r page is %d bytes' % (url, len(future.result())))


问:
How to report a bug to developers? A programmers quest to educated on bug reporting
I'm hoping to get some tips and advice on how to educate the rest of the company on how to submit proper bug reports.  Currently we get tickets like:

When I click this link I get a 404.
(They include the page that 404s and
not the page that caused it)

Sometimes the right column flows into
the button column. (no screenshot or
additional information)

Changes to xxx does seem to be working right. (EOM)

Does anyone have a bug submission process/form that guides users into submitting as much information as possible?

答:
Use a bug database and update missing details ad hoc. It doesn't matter much if you use bugzilla or just an excel sheet as long as you have some sort of list where you can populate the fields. I use just an excel sheet for a simple bug database that you handle yourself:

You can also use www.reqtest.com which I think is a very good testing and bug tracking system.

OwnerDisplayName: Ryan Detzel


问:
What made object oriented programming successful?
What is that feature according to you that has made object oriented programming so much successful ?

Message Passing

Inheritance

Polymorphism

Encapsulation

Or some other feature that you may like to introduce.

Also I would like to know that what is the connection between Abstract Data type and Object Oriented programming?

答: A feature that hasn't been mentioned yet by any of the other answers: domain modeling. Because people tend to think about doing things with or to objects, and about objects having intrinsic properties, it's very easy to model a problem or workflow using object-oriented software. Essentially, it allows us to use our existing ability to deal with nouns, verbs and adjectives in code.


问:
Should I continue to perform freelance work for customers who keep on demanding more without paying?
So a client comes to me and says it needs some work done. Basically 4 tasks, which I agreed to perform for a certain price. The customer creates the job offer (a fixed time and price job) on ODesk, I accept it, but it took some days and constant reminding for the customer to initiate a contract based on that job.

The problem is that the original task has been completed, the contract is still active, I have not been paid yet, the customer says he will pay when the project is completed, and until then, new tasks occur constantly, or changes to older tasks that require full re-doing of elements. For all of this the client promises payment. No updates from this client on ODesk, no new tasks there. I keep reminding the client about sorting out the administrative issues, but with no results. At the same time, the client pushes on continuing work, since the project is soon to be launched.

I don't know what to do.

If I refuse to perform any work without the bureaucracy, the project will be late. But it's not my fault, is it? I am scared that I might receive a negative feedback in this case, or something even worse.

If I drop out of this project I'm afraid I won't be getting even what I've earned.

If I continue like this, I'll be wasting a lot of time doing stuff similar to the stuff described here, but as a programmer (yes, it has already come to similar requests, for lots of hardcoded content).

How do I communicate with such clients in such situations? How do I avoid a conflict?

P.S. The client is a small company. Different people handle different aspects of this project, and everybody introduces their own changes to the original specs.

After 2 years: Wow! Very question! Much popular!

I decided to let everyone in on the ending of this story. I've confronted the customer, explained that I will not work until I get paid for what I did, and until a hourly contract is open. They paid me the next day and opened a contract. A fruitful, but short collaboration started. Everyone was happy. Except I didn't get any feedback.

答:
What does 'complete' mean?  Does it mean 'All the tasks in the contract are done'?  If it does then your client is clearly in breach of contract and you should consider getting a lawyer to write him a 'friendly' letter to remind him of his obligations.  You should keep that as a last resort though, and try to take a more diplomatic approach, such as trying to renegotiate the contract to include the tasks he's adding on on contingent that a) you get paid for the work you've already done as per the terms of the original contract, and b) you'll also be paid for the extra work done.

If the contract stipulates that you'll be paid when the project is 'complete', however, then you might be in trouble.  Ask any good developer and they'll tell you that software is never complete, it's either under maintenance or it's abandoned.  If you agreed that the client can pay on completion and it goes to court, his defence will probably be that the project is not complete because there's a huge list of requirements he added to the project that you've not done.

I hope your contract states that you'll be paid on fulfilment of the requirements defined in the contract.  If it is, and if it's clear that your client is deliberately jerking you around and trying to extract work from you that you never agreed to, then you have options.  If it says "payment on completion" then you may have considerably fewer options.  You could try renegotiating the contract but if he's not willing to budge then I'm not sure where you can go from there.

EDIT TO ADD: The "everyone keeps adding requirements" comment at the end of your question is ringing serious alarm bells with me.  I hope you've not accepted any of the requirements anyone other than the person you negotiated with to the work list!  You should accept requirements and change requests from only one person, otherwise chaos can ensue.  Person A might think it would be neat if you added feature X to a project, but if it's person B who's paying and they don't know person A added a feature to the project, they could get the impression you're adding stuff they didn't ask for to the project just to get more money out of them.  That's bound to result in bad blood.  Worse, you could end up with a total mess of a project with a load of conflicting requirements and code that doesn't fulfil its original purpose because it's trying to please a load of other stakeholders as well.  There needs to be a well defined process for adding requirements, and the person who pays the bills has to be fully aware of any requirements that get added.


问:
Rush to client-side in web development
In the past few months, I recognized a big excitement about client-side scripting in web development. But while server-side technologies are mature, stable and well accepted by backend-developers, client-side technologies are immature (i.e. compared to big server-side framework) and disliked by many long-established developers. Nevertheless everyone is doing client-side development these days. I personally expect those big server-side frameworks to disappear in like 2-5 years, watching the current trend.

Why is that so? How could the new and "diffuse" client-side developing in HTML5/JS possibly be superior to big and well thought server-side solutions?

答:
Client-side web development is strongly coupled with web browsers and changes in them over time. The solution you provide now may not work in a couple of months due to significant changes in the page rendering engines of web browsers. Some browsers are/were incompatible with standards and therefore required even more extra effort from the developers just to achieve expected result.

There are some solutions trying to fix this issue. For example if you use jquery you get assured your script will work on the browsers supported by this particular jquery library. But it's only up to its authors to provide you compatibility with some/most/all the browsers. The question is which team will support you better. Will it be motools team, jquery team, other team? If they don't provide support to a particular web browser, your project may not work in that browser.

The excitement you seem to have has been around for a long time. I saw it when Shockwave and its successor Flash were introduced, there was a "big comeback" of rich user interfaces once complex js libraries were shipped, first with motools, then with jquery (I started using them in this order). There was Flex and JavaFX. But none of them can get a big share in the market. Some require plugins which in time often expose end user to security vulnerabilities, others may not work on client side due to some custom settings (e.g. JavaScript disabled in clients' browser).

On the other side, server-side solution is usually written only once. You don't need to worry that everything will fail and will have to be rewritten once new Firefox/Chrome/IE/Opera gets shipped. You don't also need to worry that client will try to tamper your app and/or corrupt the data.

Title: Rush to client-side in web development


答:
First of all, the user doesn't see (and sometimes even doesn't care) what is no the server. No matter how well the server-side code is written, the users won't appreciate the application if the client part isn't done well. Sometimes even the nice UI is more important than the functionality.

A big and powerful server hosting is quite expensive. It is much cheaper to implement some of the logic (except validation) on the client-side. So you could use a smaller (therefore, cheaper) server hosting, since it would not be loaded that much.

These are the reason that, despite the instability, client-side technologies are gaining more popularity. Besides, JS and HTML/CSS are supported by (almost) all modern browsers.

These two parts of applications cannot exist separately. And the Internet doesn't seem to be leaving anywhere in the near future.

I don't think that big server-side frameworks are likely to disappear either. There will always be companies that can afford them, and will use their significant advantages.

Title: Rush to client-side in web development

Body:
In the past few months, I recognized a big excitement about client-side scripting in web development. But while server-side technologies are mature, stable and well accepted by backend-developers, client-side technologies are immature (i.e. compared to big server-side framework) and disliked by many long-established developers. Nevertheless everyone is doing client-side development these days. I personally expect those big server-side frameworks to disappear in like 2-5 years, watching the current trend.

Why is that so? How could the new and "diffuse" client-side developing in HTML5/JS possibly be superior to big and well thought server-side solutions?


答:
Server side will always be around. You can't sit on client-side for everything. For example,
 you wont want to use a Backbone.js MVC design for your micro-controller sending you parameters in real time from a production floor overhead crane.

Don't believe the hype.

Title: Rush to client-side in web development


问:
Is defining a variable to name a method argument a good practice?
For the sake of readability I often find myself defining temporary variables while calling functions, such as the following code

```<code>var preventUndo = true;
doSomething(preventUndo);
</code>```

The shorter version of this to this would be,

```<code>doSomething(true);
</code>```

But when I come back to the code I often wonder what true refers to. Is there a convention for this kind of conundrum?

答:
One should avoid passing boolean variables as arguments to functions. Because functions should do one thing at a time. By passing boolean variable the function has got two behaviors. This also creates readability problem for at a later stage or for other programmers who tend to see your code. This also creates problem in testing the function. Probably in this case you have to create two test cases. Imagine if you have a function which has got switch statement and changes its behavior based on the switch type then you have to have so many different test cases defined for it.

Whenever one comes across having a boolean argument for the function, they have to tweak the code such that they dont write boolean argument at all.


答:
I've made the switch in 2009 from a server-side PHP framework to a client-side ExtJS solution tied to server-side web services.

Reasons for the migration for me were:

Better security by reducing the amount of endpoints and code on the server.

By moving to web services you validate input at the web service boundary and have more exact control over your server's I/O. There is no server-side UI layer to muddle up your security architecture.

Improved performance because of fewer server roundtrips

The architecture changes so data fetches can happen less often and data can be cached locally with the UI rendering not requiring a roundtrip at all. Roundtrips are what kill web app performance.

Improved performance because of cacheability of UI

The UI layer can be hosted on a CDN completely. I've even built offline web apps by shoving the UI code into HTML5 app cache.

Higher fidelity of UI (rich client-side controls)

3rd party developers can use the same API as my own front-end is using, and I can easily reuse API's across modules if they share features.

This means less development, QA, documentation, ...

I like programming in JavaScript better than PHP, Python or Java

But, make no mistake, what's happening now is a hype. It will blow over and many web apps will use a server-side UI architecture again.

Title: Rush to client-side in web development


答:
This story has always had two sides to it; both server-side and client-side code have their pros and cons.

Advantages of client side scripting include:

Can be made more responsive, extensive changes are possible without server round-trips.

Code runs on the client, reducing resource usage on the server.

Separation between logic and presentation becomes physical.

Sometimes easier to load-balance, especially if per-request authentication is used.

But server-side script has a lot of advantages too:

You control the machine the code runs on.

Pretty much anything is possible - if your server can do it, so can your script.

Users cannot modify your script before running it.

Users cannot use script blockers to prevent your script from running.

Users cannot see what your script does, they can only observe the output.

The code will work reliably with every client you can imagine, including screen readers, textual web browsers, search engine spiders, scrapers, accumulators, IRC bots, super-low-end machines, scriptblocked browsers, you name it.

User plugins are less likely to break.

For highly dynamic web applications, the client-centric approach has always been a popular choice, because it's the only way to provide a decent responsive desktop-like user experience: without client-side scripting, every one of the user's actions requires a round-trip, which means at least half a second delay, typically more. But for an informational site that is basically just a bunch of static pages served from a database (say, wikipedia), the advantage is marginal, while the benefits of server-side scripting are still overwhelming.

The observed hype comes from a combination of two recent developments:

HTML5 and its corona of related technologies. It took way too long, but now we finally have a standard that contains everything you need to make those dynamic desktop-like web applications without piling up hacks, and mainstream browsers that implement them properly.

Available processing power. Today's commodity desktop PC's are just as powerful as an entry-level web server, customer-grade cellphones are practically 2005's desktop computers, and modern javascript implementations are efficient enough to tilt the performance balance: by now, client-side resources are cheaper than server resources.

In fact, nothing has changed in terms of what the server-centric and client-centric approaches are good at; what has changed is that client-centric is now easier and cheaper to do and performs better than a few years ago, making it a viable choice for a lot more applications than it used to be.

Title: Rush to client-side in web development


答: This very likely isn't their program. I would point out to them that you are unpaid, so this is not a work for hire, therefore it is yours. Offer to sell it to them for 5k and think of it as a nice bonus. If they fire you send a notice revoking all licences to use the app. Do not sign anything until they have a cashiers check and you look over the contract with a lawyer.</p>


问:
Sequence Diagram for Response Redirect in ASP.Net Webforms
In asp.net webforms I have a home aspx page that has a “Go” button. [This is the only control in this page]. When this button is clicked, the user is redirected to “UserProfile.aspx” page.  How can we represent this redirect action in sequence diagram? Any reference articles/blogs for this?</p>

答:
It is a bit strange to do it this way, because what do you try to tell your audience ? I would not use a sequence diagram for this but make a navigation map.

If you really want to do it, below is what Visual Studio can generate :


答:
At first, you need to define an ontology: what are the "things" that need representation in your problem domain, what are their properties, how do they link together? If you're trying to define a general standard for sharing data, then your ontology needs to cover any of the cases that could come up in a rather broad collection of scenarios.

Once you've got that semantic bit out of the way, the next part is comparatively simple: just define a data format that can express all of the above :-). Seriously, choosing the technology to represent the problem domain is going to be much less problematic than unambiguously expressing the problem in the first place.

This is definitely "the hard bit" with medical data, where multiple existing practices and techniques already exist: where someone has recorded that treatment was started, have they given you the calendar date, or the number of days after diagnosis, or the number of days after symptoms were first presented? Which of those is important? Can you "standardise" that into a single representation in all cases?


问:
What are use cases and advantages of pointers?
I often struggle to see the advantages of pointers (except for low level programming).

Why use of char* instead of a String or char[] or what advantages pointer arithmetic brings.

So what are the pros and use cases of pointers?

答:
Complex data structures. You can't build something like a linked list or a binary tree without pointers.

There are no "pros" and "cons" of pointers. They are just a tool, like a hammer.