Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Wednesday, November 1, 2023

Coding: Design Pattern Factory: Comparing Tutorials

 I had some difficulties understanding the design pattern factory and watched a few tutorials.


The tutorial I found most helpful for understanding: Christopher Okhravi's Factory Method Pattern – Design Patterns (ep 4)
(https://www.youtube.com/watch?v=EcFVTgRHJLM&ab_channel=ChristopherOkhravi)

This tutorial was good too and for me a good supplement to Okhravi's tutorial: Code with RaiGenics' Factory Method in C# I Design Pattern (Part 3) - How and When to use Factory Method
(https://www.youtube.com/watch?v=tdMOdeewTnc&ab_channel=CodeWithRaiGenics)


This may potentially due to it being later and I have been understanding a bit more after each video. I do not think so but wanted to mention for transparency. Below is the order that I watched the videos.


Microsoft Video Studio

https://www.youtube.com/watch?v=JEk7B_GUErc&t=427s&ab_channel=MicrosoftVisualStudio

This just did not help me understand why I needed a factory. There was an example about pizza which I later learned from my recommended video by Christopher Okhravi that this is from a book called "Head First Design Patterns" which sounds like the exact same example.

PRO: Robert Greene asked a couple good questions. Otherwise, nothing obviously helpful to me. It was the first video I watched. Watching again after understanding does not seem useful. 

CON: The tech guy (Phil Japikse) is not very good at answering or describing the questions by host (Robert Greene).

IAmTimCorey

https://www.youtube.com/watch?v=2PXAfSfvRKY&t=246s&ab_channel=IAmTimCorey

I am usually a fan of IAmTimCorey videos but this video was very hard for me to follow as there were too many new terms for me to learn and understand like delegates, dependency injections, and Blazor. This may be good for those who have more experience.

PRO: This may be helpful later when I get into Blazor.

CON: Too advanced. I need to understand delegates, dependency injections, Blazor, and probably a few other things that I do not understand enough to even not understand.

Code with RaiGenics

https://www.youtube.com/watch?v=tdMOdeewTnc&ab_channel=CodeWithRaiGenics

This was a bit too technical to start off with but is also a good tutorial. This is include a good example in C# which is what I ultimately needed too.

PRO: Used most basic example and basic code to demonstrate factory design pattern.

CON: Seemed too technical at first but upon reviewing it again later, this video probably would have been fine. Although this had the best code example, it was just short of one of my biggest question. After I create the object, it is in the base class like IMobile. After I get the object, what if I want to use a specific method in the sub-class like SamsungA9? I am sure I can look this up and could be unrelated. I personally would have preferred that it added that one bit anyways.

Christopher Okhravi

https://www.youtube.com/watch?v=EcFVTgRHJLM&ab_channel=ChristopherOkhravi

PRO: I understood the example better. I agree the example about the pizza was a bit confusing to me too. The pizza example is still a bit confusing even after understanding the factory pattern. The UML diagram was also helpful in answering my question on what is the difference between interface and factory pattern. The other tutorials almost seemed like it was just explaining how to use an interface. The UML diagram helped me get over that hump. I would recommend this video as a good overview for the design pattern. For me, it was a bit better than RaiGenics'.

CON: No code example but it obviously was not meant to have one as it was a generic overview. For example, RaiGenics' code sample was the most helpful. For more advanced, Tim Corey may eventually be an ultimate code example as I do plan to eventually work with Blazor.


Summary

My recommendation is to start with Christopher Okhravi then RaiGenics and finally Tim Corey. MS Visual Studio was not helpful to me before or after understanding.

Monday, August 8, 2022

Life: Encouraging People to Learn to Code/Program/Develop

There is a lot of context to baseline here. By people, I mean the general population. By coding, I mean software programming like assembly, C#, or C++ on a very basic level. And the issue I am try to address is why many people find programming too difficult to want to learn.

Although easy and hard are relative, I am going to generalize that when most people say that it is hard, they mean that they do not want to bother learning or even understand it. Yet, they can follow the most complex story lines, office politics, and so many non-standard social norms on a regular basis.

We are in an era where technology is being embedded everywhere. Knowing how to code will likely be needed everywhere whether you are a waiter, box mover, design, doctor, lawyer, president, etc.

To me, the odd part is that coding uses a very tiny subset of our language yet executes the result nearly 100% of the time. So it should not be difficult to at least understand. In some ways, it basically is a simulation of logic.

The troubling part when I hear people not wanting to understand coding is that I "hear" them say that they don't want to understand logic and leaving that for someone else to fix.

Saturday, June 12, 2021

Info: Getting network shares library with C#

Goal: to get a list of available shared folder names given a remote server name. 


1. I believe this uses the user that is logged into the site. https://www.codeproject.com/Articles/2939/Network-Shares-and-UNC-paths

This was super easy to set up.


2. This is what I wrote if logging in with a specific user:

ManagementPath path = new ManagementPath();

            ManagementClass shares = null;

            ConnectionOptions co = new ConnectionOptions();

            co.Username = "login";

            co.Password = "password";

            co.Impersonation = ImpersonationLevel.Impersonate;

            path.Server = FolderPath; //"devaappwebec01"; // use . for local server, else server name

            path.NamespacePath = "root\\CIMV2";

            path.RelativePath = @"Win32_Share";

            ManagementScope scope = new ManagementScope(path, co); // use (path) for local binds

scope.Connect();

ManagementObjectSearcher worker = new ManagementObjectSearcher(scope,

            new ObjectQuery("select Name from win32_share"));

            ManagementObjectCollection moc = worker.Get();

 



Friday, May 14, 2021

Anecdote: Replacing plaintext user id and password with password vault

I just reviewed code where they are trying to replace configuration files that have user ids and passwords in plaintext to a password vault. The hilarious part is that they comment out the old configuration file which contains the credentials.

The habit here is that developers are always afraid to lose code even if there exists a million backups (or maybe because their exists a million backups), so they comment out old sections.

The code even goes through two code reviews before it reaches me. 

#GiveMeTheirPaychecks

Thursday, August 6, 2020

Code: A potentially dangerous Request.Form value was detected from the client

Some notes on how to resolve this error message, as I keep need this reference:


Page
validateRequest="false"


Site
<httpRuntime requestValidationMode="2.0" /> to web.config


Sunday, July 26, 2020

Buggish: Amazon WorkSpaces Locked Shift Key (Unresolved / workaround) Update: Resolved? [2020-07]

Replicate: Unknown
Frequency: Multiple times a day, but can get half a day without it occurring
Environments: Two different machines running different versions of AWS Client. Issue seems to be similar even though different OS and different clients.

Workaround: Turn on caps lock, then turn off caps lock. Repeat if necessary. Toggling may not work if toggle too quickly. At most 3 times, but works every time.

Behavior: Basically, the shift key locks on AWS because all actions appear to be as if the shift key is down. Like highlight text between two different mouse-clicks in a text box, select multiple rows in spreadsheet, etc.

Shift is not locked on my machine. This only occurs in AWS. Pressing the shift key does not appear to do anything which kind of makes sense because it should act as if shift key is down. But release shift key does not return the state back. I found toggling caps lock will return the shift key state.

I do not use caps lock at all, so this is not caused by using caps lock. I figured this out randomly.

I cannot guarantee that this does not happen when not using the shift key as I use the shift key very often. I do also use both shift keys (not at the same time). It does seem to occur more often when I am coding C# which uses a lot of shift keys for curly braces and for sql because I cap the keywords. I want to say that it seemed like this issue still occurred once or twice when there was no shift key used, but this seems to be a very rare occurrence.

It may be possible that there is a delayed or lag response to a shift key press which would explain why it occurs more often when I am coding. Oddly, I can also go a few hours without this occurring. This could just be my mind playing tricks, but also seem to occur less often when I work off peak-hours.

There also seems to be quite a few posts dating back to 2016 with no solution so I am not expecting this to be ever resolved, so beware if you decide to use AWS.

Update 2020-09-03

Interesting, not long after this post... this problem has gone away. I cannot recall when this stopped but feels like at least a couple weeks. Has this problem been resolved? Seems like it.

Update 2022

As of 2021, we have moved from AWS to Azure so there will be no more updates on AWS.

Friday, May 22, 2020

Thursday, March 5, 2020

Coding: Difficulties of Learning New Programming Languages (Python/Django for example)

I always assumed that it would always be easy for me to pick up a new language since I have already had experience with Java, VB, C#, and several scripting languages. This was kind of the case in the past, but not so much in the modern era.

Knowing a programming language definitely helped me learn Python. What makes learning today is not the language itself anymore but all the frameworks, configurations, all the options, and all the new standards.

At first I spend so much time in just figuring out all the environments that Python can be used in. Maybe this step could be skipped if you already stuck on a certain platform like Windows, Linux, or MacOS.

Then I spend a lot of time just how to build out the infrastructure, like Apache, Django, PostGRESql, MariaDb, etc. Yet, I still kind of regret not going simply with mySQL. I imagine this would be longer for first time programmers as I already had some experience with IIS and MS SQL.

Finally the most time-consuming part of a new language is learning its new framework, process flow, terminology, plug-ins, and standards. For example in Django, I spent the last few days figuring how the engine picks the templates that you designate in the views.py after I built a second application. By default, Django looks through each templates folder start with the order the apps were listed in the settings.py.

At this point, I started to understand the importance of community support. I just could not find the proper wording to find the solution to my problem. My problem was that I attempted to make my template folders have the same structure. Because I did not learn the folder standards yet, I had some files in the template root folder like the index.html. So when I try to access my app2/template/index.html, my page showed my home page (app0/template/index.html). This did not make sense to me because I assumed that the views.py in app2 will use the index.html in app2. I kind of guessed this was the case so I tried to find a way to force the rendering to pick app2's index.html which led me down a lot of rabbit holes.

Each time I meet a new challenge, I find not only do I spend time to research the problem but in some cases, I have to also redesign my application to fit the community's standards. One example is learning about PyLint in its standard on documentation. I had to go through each file to provide documentation which is a triple quote description after the component declaration. I have been using the same method as MS Visual Studio which uses comments prior to the component declaration. It also checks naming schemes, tab spaces, proper empty lines, lines with spaces, etc. Although great for consistency, this took up a lot of time to learn and implement. I do not feel any of my past experience made this process any simpler or faster to learn.

In summary, I am starting to understand the demand for specific language requirements in current job descriptions. I think I would definitely learn much faster with an experienced language programmer to guide me through the differences. I feel that I will still learning faster than a new programmer but will still take time to learn the framework and learn how to troubleshoot compared to an experienced programmer of that language. I feel that it would take me about a month to be somewhat familiar with the new language, tools, and standards; probably a couple weeks if I had a resource dedicated to point me in the right directions. I probably spend 80% reading solutions to different problems similar but not exactly.

Wednesday, October 9, 2019

I stopped using Microsoft Visual Studio and Azure (2019)

I am mostly a hobbyist developer. I had moved to more process management in software engineering. So the cost of paying for the professional version ($1200 / $800) of Visual Studio is quite steep even though I still paid for several years. I am aware there is an Express version which I had used initially but the professional provided a lot of neat features also provided Azure credit so I figured it compensated some of the cost.

I was content with paying but then my real work got busy for several months, also many things came up in my personal life, so I had neglected programming for a bit. When I returned, I realized Visual Studio no longer let me log in. I eventually found that my subscription had expired. I then noticed that I had received a bunch of emails that said I was overdue. This was due to a fraudulent charge on my credit card which was canceled, and that card was the one on record to renew.

This was extremely confusing, because I thought they had moved to subscription basis which I had been paying. When I paid all the overdue costs, I was still unable to use VS 2019. But somehow VS was separate and that had expired several months past, so it will cost me another $1200 to repurchase to use. I am still a bit confused exactly what is what, like what was Visual Studio and what was monthly subscription.

My current understanding is that I was paying monthly for Azure which does not include VS. I had paid for VS the prior year. Sadly, I didn't notice that I had been paying some much to MS for so long. So I still have Azure to host my site temporarily, but absolutely no access to VS. But if I paid for VS, then I should basically own my copy of VS. After talking to support, this was confirmed to be the case. I was unable to find a key in my MSDN subscription. I just grew tired and frustrated, then just refused to use VS again... not even the Express version.

On top of that, since I had purchased VS 2019, I should have had $50 monthly credit to Azure so why was I paying the Azure monthly costs (which was under $50 / month)?! Ugh.... this is so painful.

In Summary

I had once forgot to renew in the past and paid the full cost, so this is the second time. I was barely ok with the cost. Then they moved me to subscription basis which I had complained about because I just wanted to pay a flat amount. Then I found out that I still had to pay the VS subscription and I guess I was paying the Azure subscription. I had been using VS for over 10 years, maybe around 15 years.... and absolutely no sympathy for my situation. I have been a promoter of MS VS, .NET, and MS SQL, but no longer. I don't hate them, but definitely no love anymore. 

And so, I have moved to Google Cloud, Linux, Python, Apache, Django, and Postgres. After one week, the pricing scheme is very reasonable for hobbyists and people who wants to experiment before going full production. First impressions for this new tech stack will come in the future.

Will I go back? Maybe if there were some changes, but unlikely. I'll continue to use MS Windows, although a good chance I may move

Tuesday, March 14, 2017

Buggish: MySql.Data, unable to compile

Error    1    Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
My Solution: Use the stable version in Visual Studio 2013 NuGet Package.

My steps I think I've taken:
1. Used NuGet Package to install latest version (7.0.6)
2. Attempted to compile, completed compile then realized that dll was not in the bin folder
3. I didn't realize that NuGet Package is saved in the packages folder, so I downloaded the source mysql-connector-net-6.9.9-src
4. Compiled
5. While trying to find my project folder, I stumbled onto the package folder so I used Add Reference to add the dll for 7.0.6.
6. Compiled, and I got a similar as the one above. (Unsure if the version is the same)
7. I removed the reference and tried to reinstall via NuGet (received similar error)
8. Repeated several times with the compiled code, modifying web.config, restart, reboot
9. Finally, I tried to download the latest stable version.

I am not familiar with NuGet, assemblies, and GAC. I am familiar with the terms but usually have worked by following directions so have not delved into them much before. I do not think my understanding has increased any bit after this either, but hopefully this help someone as I haven't seen this solution.

Saturday, March 4, 2017

Javascript - Find elements by the "for" attribute

            function findLableForControl(el) {
                var idVal = el;
                labels = document.getElementsByTagName('label');
                for( var i = 0; i < labels.length; i++ ) {
                    if (labels[i].htmlFor == idVal)
                        return labels[i];
                }
            }

This function is handy when working with C# CheckBoxList (or really any of the C# lists). When creating javascript to manipulate the list, C# does not provide ID to the label, rows, nor columns. Thus to find the label, only the "for" attribute can be used to search.

Reference

http://stackoverflow.com/questions/285522/find-html-label-associated-with-a-given-input/285575

C# DataBinding does not contain a property with the name with custom class object and CheckBoxList

I get the error "DataBinding: class1 does not contain a property with the name prop1"

public class1 {
  public string prop1;
  public string prop2;
}


My setup was an object array of class1 which has a property prop1 and prop2:

class1[] arrClass = new class1[arraySize];

Then I set the DataTextField and DataValue:
checkboxlist1.DataSource = arrClass;
checkboxlist1.DataTextField = "prop1";
checkboxlist1.DataValueField = "prop2";
checkboxlist1.DataBind();

This throws the error above. The fix is the lack of accessors in the class, class1. The class should be corrected to the following:
public class1 {
  public string prop1 { get; set; }
  public string prop2 { get; set; }
}
 Technically, set is not needed.


Reference

https://msdn.microsoft.com/en-us/library/aa287786%28v=vs.71%29.aspx

Saturday, November 21, 2015

.NET Find User Control in a Master Page, or really any control

Solution: Set the control you want to access to public or whatever accessibility is needed for your application. To do this, you will need to go into the designer.cs file (assuming you are using visual studio; if not, you should already know how to do that).

Error: (When using FindControl) An exception of type 'System.NullReferenceException' occurred in XXXXX.dll but was not handled in user code



Better solution: Create a public function within the master page to do the actions needed.


Scenario: I wanted to create a dedicated login page and had a login process in the master page. The need was to hide the master page login for the login page.

Although I have not considered during the design phase, this can also be used to manage the menus.

Saturday, May 9, 2015

Hyperlink in Gridview

There is no way to decode the hyperlink with gridview when autogeneratecolumns is set true. BoundField has a property HtmlEncode that can be toggled to false to allow hyperlinks.

This was needed for blogs and changelogs but not for defect resolutions due to wanting to deploy the actual html. Not sure what happens if I need to include a link and actual html.

Monday, March 9, 2015

ASPNET Sessions and Response Redirect - Why logins do not always work after logging off

This is the first time that I got around to building a custom login user control. Typically, I build the login as part of the master page. Because of this change, there was a problem I ran into while testing the code. The issue was that I was unable to log into my application right after I log off. I can log in in the very first session or login again after it fails.

This issue is not a huge deal but can interfere with the user experience which makes it a big deal. But how often does a user log right in after logging off? This should not happen often and the user will likely naturally try again.

Any case, I found that I cannot Clear and Abandon a session in the same page transaction as I set a new session. Essentially, I found that this issue occurred only on the logoff page. I can log in twice because the page is redirected to the home page after the first attempt thus leaving the logoff page.


Summary

Not IsPostBack will prevent the issue that I ran into. Executing session's clear and abandon will trump any sessions set within the same page transaction, even if it is "executed" earlier in the code. By using Not IsPostBack will prevent the clear and abandon code to be executed when the Page_Load method is executed after clicking on the submit button.



Off-shoot issue

I had ran into a different problem earlier in my career (I think this may already have been fixed in the later .NET Framework versions), but in case the above does not help... here is an article that provides detail on using sessions and page redirects.


Reference

Friday, February 27, 2015

CSS - div #foo vs div#foo - How a space cost me an hour worth of frustration

I start "coding" again and quickly ran into the "pulling my hair out" moment on why I cannot troubleshoot the simplest of things. By "coding," I mean working on stylesheets. Yes, I have not even reached the real code stuff (yet I suppose I do have much fewer frustrations there because the syntax is more strict there).

So, I am working on a layout with a site div that contains many sub-divs which may also have additional sub-divs. I was able to get styles up quickly and easily, then I wanted to add a width to the highest parent of divs and for some reason it would not work. I tried all sorts of combinations of switching ids, spell checking, and checking other divs. It works for all the divs except the parent one.

Here is basically my layout:

 

 

   

 

 




And my style sheet:
div #foo { width: 800px; border: 1px solid black; }


No matter what I did, nothing happened, yet if I changed #foo to #top or any other id, I would have a banner. Then finally, I removed food and made it separate from the other divs completely. Suddenly, I had no borders at all except for left, content, and right.

This made me realize that having a space meant the sub-object of the previous object. In other words, CSS is looking for an object named foo inside of a div. Because foo is the parent div, there is no parent div thus CSS does not find a foo instead a div. This is why all the other divs changed accordingly because they were all within a div, foo (whether it was named or not).

So the proper way that I should have coded this was to remove the space between div and #foo, thus making it div#foo. All my problems went away! FINALLY! Nothing like this to remind how foolishly amateurish I can be.

Even #foo would work, but I thought I would be cool by being a little more specific. Even in hindsight, I should have known this because I have used similar practice with classes. Although, I admit that I actually didn't know this difference even though I have developed websites for several years. Usually, I have a placeholder div so I never ran into this problem but not realizing that was what kept all my designs working. Of course, I decided today to not do that because I just felt like making the design insignificantly more efficient.

As for searching on google, this was not easy to find because "css style not working" brings up a lot of results. And "css style working on all objects except parent" did not return what I was looking for. Defining this issue is still not simple even though I have figured out the problem. Perhaps, this problem is too easy to even be mentioned. Hopefully (or perhaps not), I am not the only person to run into this problem and this would help someone in the future........ perhaps my future self!

Tuesday, February 10, 2015

I am not a fan of agile / scrum (Software Methodology)

I am not pro-agile, but also not anti-agile. I did just enjoy reading a post by Giles Bowkett on "Why Scrum Should Basically Just Die In A Fire." I think agile methods (including Scrum) can work, but time morphs any processes and agile is no different. Giles presents a lightly-humored touch on how Scrum can go wrong.

For me the biggest issue with agile (at least today) is its inability to weed out poor-performing members. Even weeding out bad-performing members is pretty difficult. The second biggest issue with agile is the ability to game the company system. Another big issue that most sites do not point out is that agile is not good for high risk solutions, especially solutions that may determine real life and death risks like medical solutions or an airplane.

There are other issues that agile also do not manage well is regression test. It requires that it to be automated which is fine, but how would it regression test features that take up real physical time like scheduled jobs that are triggered daily or even weekly. Agile also loses performance when dealing with multiple components or multiple environments, where the project essentially becomes traditional methods to coordinate all the different pieces.

Poor-Performing Teams

My biggest problem with poor-performing members is that we have the misconception that those members are dumb. In reality they are just not good at their role, but are smarter than people credit them to be. So this allows a lot of freedom for people to game the system or start politicking.

The easiest excuse is that agile is new, so they still need to work out the kinks. Blame the other group, blame the requirements, blame coding, blame testing. Everyone just points fingers at everyone else. Sadly, these poor-performing teams come out looking better because they are more prepared to blame others while the good teams were working how to fix the issues.

Even if you can isolate the team, identify the individual is even more difficult. There is less information as there is less focus on documentation (if there is an documentation at all). Is the problem with the scrum master not leading properly or the developer not coding properly or the tester not testing sufficiently? Or the scrum master does not have proper support or the requirements are consistently poor or test cases ill-defined? Finding the high-value and low-value members is like a game of mastermind.


High Risk Solutions

I find it odd that I have not come across any sites, posts, or forums (even anti-agile fanatics) mention that agile is not advisable for solutions that have high risks if something does fail. I surely do not want to be on an airplane that went through an agile process... unless maybe if it were on its one millionth iteration and the last 500,000 iterations had no deaths. Or use the laser eye surgery. With my luck, I will probably be that one test case that no one anticipated.

I am also sure that financial companies would not want to risk millions of dollars due to a flaw in the system. I doubt explaining that they didn't provide the proper requirements would make financial companies feel any better. Telling them that the next iteration would correct the problem would not be much consolation. 

Or an online bank losing your life-savings. An individual losing $100 of life-savings will likely be just as angry as another person with $1,000,000 of life-savings. Sure there is insurance for that too but who really wants to go through that experience.

Sure some solutions do not carry such risks like Candy Crush or Farmville (there have been extremes with some video gamers that could probably prove that wrong too). The problem is defining where that line is like a cloud solution that promises 99.99% uptime. Is the risk worth all the customers possibly switching to your competitor?


Documentation

How many people do you know that the value to agile methods is "comprehensive" documentation in its core value: working software over comprehensive documentation? How many of those people even know what that mean? Most people hear "no documentation is needed" (at least the people I know). Not sure how many times I had to point out that we still need some documentation after hearing that they are not supposed to provide documentation anymore because they went agile.

There is definitely something wrong if that value even has to be stated. What company would not love to drop documentation as part of the process if the software just worked? Writing documentation takes up time, and to our corporate world, time is money. I mean they will drop testing if that would save them money too. Besides time and money, I think traditional methods can also drop comprehensive documentation so making it a value of agile is kind of redundant. 

Comprehensive documentation came out of technical writers wanting to keep their job and managers wanting to make people as replaceable as possible which means that the documentation also needs to be continuously updated (mostly the latter which coincidentally didn't get complaints from technical writers). If it is faster to read code to learn what it does than it is too read documentation, the documentation is too comprehensive. I have personally read some old corporate documentation that went into such details as even providing illustrations on single-clicking versus double-clicking or how to move the mouse or how to insert a disk (although the younger generation probably would need that step today).

But my main issue with agile is that people seem to take this to mean "no" documentation. Although it is not stated that way in the manifesto, many people perceive it that way. Developers don't want to document, managers don't want people to waste time documenting, so it appears like a win for everyone. 

That is until 6 months later and the whole development team has changed. New updates are needed on the old code which no one knows about. No documentation, so more time is spent figuring it out. Code is eventually updated and passes the end-user acceptance test. Deploy the change then realize an old process has changed which broke something else. Maybe the change was a comma instead of a semi-colon which passed regression test but fails for the client. The point is more time was spent than was necessary. Management is going to put this as a lesson learned or retrospective, then will require more documentation. 10 years later and we are all going to be back with the issue of comprehensive documentation for agile and traditional methods (or whatever new method name it will be in the future).

I haven't even touched on audit which is already a nightmare with traditional methods. Surprisingly I have not had to experience audit with agile project (yet), but I would guess that it would be just as difficult as traditional in its best case. More likely it would be more painful due to lack of documentation which is a majority of the problems I face in traditional methods. But I supposed it could be easier just to tell the auditor that it just does not exist than trying to hunt down the document, then let someone else worry about what process need to be put into place to "correct" the audit problem.

Solution Complexity

Assuming a great and awesome agile team, the agile method will slowly become similar to traditional methods as the solution grows in complexity and scale large enough to partner with other groups. Having to coordinate times, priorities, and many values to traditional methods, agile cannot avoid certain decision gates needed for multiple team coordination. Agile can work purely in the requirements through development phase, but once it reaches integration another branch of code is required. Then the company will also need another set of testers and developers to fix issues because the agile teams are to be working on the next iterations. If the same team is used, then most of the agile iterations are pretty moot.

Assuming another team is available to support code that is being prepared for production, processes need to be available to merge code to any code that is still open. Further regression test is required. And this is probably the easiest and most regular process.

How will the group manage if there is a production issue that needs to be corrected while in the middle of an iteration? What if it happens to be in the middle of an iteration and in the middle of integration? Is there a separate team? Does integration stop to work on production issue? Now there are at least 3 branches of code being developed. That is only if the code is for one group.

Working with multiple groups, departments, partners, etc., there is bound to scenario where there is not enough resources. In traditional world, all the requirements are coordinated. For agile, this may be more difficult because iterations now have dead-lines which is almost counter to its values. One of the groups may keep its agile schedule, but the others have to coordinate accordingly to their dependencies. Working with other partners may even mean coordinating different flavors of agile methods.

And this is becoming more and more commonplace, as companies have software solutions for billing, accounting, finances, manufacturing, sales, and other departments. Then you want to interact with other companies.

Conclusion

I think agile is basically the same as traditional but just from a different view angle. I think traditional has always been trying to go agile, and many companies probably have made it work. Most of those methods are probably more agile than traditional compared to the corporate world. I think some would argue that it was more or less lean processes like six sigma.

I spent most of my career with small to medium sized companies which basically are traditional methods in a very fast paced world which forced us to be very agile-like. So when I learned agile, most of it was already very familiar except without all the fancy terms and ceremonies. The learning curve was actually harder when I worked with a corporation sized company where the bureaucracy was so daunting.

So, I feel that agile is either the leanest process of traditional method or a traditional method that goes through many prototyping that just never gets refactored. In the smallest of worlds, developers at the very beginning is the truest form of agile where we our own client, product, end-user, developer, and tester. Came up with an idea, tried to program, test, check with initial idea, come up with new idea, develop, test, accept the result, repeat if not acceptable, then becomes final product when accepted.

Monday, November 3, 2014

Coding: SqlCommand Add vs AddWithValue

I ran into the issue but had simply converted it to a string value which worked for me. Later I was cleaning up my code and realized that Add was deprecated then out of curiosity looked up the difference. I thought this was interesting because on how 0 and 1 were implicitly converted differently.


vcsjones (@stackoverflow):

The reason they deprecated the old one in favor of AddWithValue is to add additional clarity, as well as because the second parameter is object, which makes it not immediately obvious to some people which overload of Add was being called, and they resulted in wildly different behavior.
Take a look at this example:
 SqlCommand command = new SqlCommand();
 command.Parameters.Add("@name", 0);
At first glance, it looks like it is calling the Add(string name, object value) overload, but it isn't. It's calling the Add(string name, SqlDbType type) overload! This is because 0 is implicitly convertible to enum types. So these two lines:
 command.Parameters.Add("@name", 0);
and
 command.Parameters.Add("@name", 1);
Actually result in two different methods being called. 1 is not convertible to an enum implicitly, so it chooses the object overload. With 0, it chooses the enum overload.

Reference

http://stackoverflow.com/questions/9999751/difference-between-parameters-add-and-parameters-addwithvalue

Friday, October 31, 2014

Coding: Name Distributions for 12k Semi-random Names

I wanted to create a table of people's names so that I have a set of data for testing purposes. I wanted the names to be somewhat more random than people I know and needed to find possible exceptions to my assumptions on names. As noted in my previous post, I have ran into quite a few exceptions and some were quite difficult to workaround (ie Muhammad ibn Musa al-Khwarizmi or Georges-Louis Leclerc, Comte de Buffon).

Before I get to some of the problems, I wanted to just post some data since it is just one of those things that I just like to do with my free time even though there may be no value to it. This is for my set of 12k names which I pulled from any lists of names that I could find (US presidents, popular scientists, soccer team members, veterans, etc.) with some diversity.

The top 10 first names are:

  1. John - 40
  2. James - 29
  3. William - 21
  4. Thomas - 17
  5. Robert - 17
  6. Michael - 15
  7. David - 14
  8. George - 12
  9. Mark - 12
  10. Richard - 12
The top 4 last names are:
  1. Brown - 9
  2. Johnson - 8
  3. Smith - 5
  4. Stewart -5
My random data search is quite dominated by males. The top female name is Susan (8). Just off the top of my head, I think at least 95% of the names are male. I will try to focus on more female dominated industries. I stop at 4 for last names because there were too few overlaps in last names.

I also did a direct aggregate of names, so names with different spellings or abbreviations would have a lower count. I have thought about creating some sort of normalized table for names (ie John, Jonathan, Johnny, Johny, etc.).

As for unique spellings:
First names - 655
Last names - 1055

Another small issue with the names are the use of accent marks. On the traditional US keyboards, accents are not easily accessible so accents may be left out (ie Zoe vs Zoë). These are counted separately in the SQL aggregates.

One of the biggest problems to this count is Asian names especially Chinese ones. Most Asian names are family names first. Although almost all Chinese family names are a single characters, there are rare exceptions to this rule. Unfortunately, I cannot read the names. Even if I assume that whatever I find are single characters, I am not exactly sure how to manage surname first whether I should enter them into the last name field because that is traditionally the family names for Americans (which most systems are based off of) and because names are split so that formalities can be added to American traditions or keep the literal that it is the first part of the name then.

This does make a difference if I were to create metrics similar to what I have above. It will be more important to keep the list as first names as opposed to given names and last names as opposed to family names. This becomes even more complicated as I read that some places like Iceland and India have other traditions to their names where there is no "family" names similar to American or Asian cultures. There are some that include the location, parent's, or parents' names. 

Or even ancient times where people only had a single name. How would I enter Alexander the Great? Given that I keep 'von' and 'de' in the last names, the most logical method is to have 'the Great' as the last name.

Also some people changed their names or inherits new names. I did not have a method for this except to just keep the first name that they had (or at least I think it was the first one). In the future, I will likely have to create an alias table to track people with multiple names.

So there came to be a lot of work to dealing with names than I had originally planned. And this shows how software planning could easily be thrown out the window. What most would probably estimate to be only a couple hours could turn into days because the architecture may change thus rippling other changes.

Coding: How to request, store, and display names from different cultures and languages?

I have found this great site that does a great job of describing the majority of cases. While trying to create a database, I had created a table with the standard first name, middle name, and last name. I had input several names to test this table. There were a few instances that had my question the method.

Before you read further, I will be coming from the standard American naming format where most people will have a first name and last name with an optional middle name. The first name will typically be the given name, while the last name will be the family name. There are rare exceptions due to the cultural or individual reasons. As far as I am aware, there are no laws to how the games should be passed from generation to generation so names really could be used in any manner in theory.

A lot of ancient names have only a single name like Euclid. I have the table to allow nulls for last name, but it still raises the question on what impact this will have on applications that may use the last name. What do people with a single name fill in forms that require a last name? He can also be identified as Euclid of Alexandria. As some names make use of the location names, "of Alexandria" could be designated as a last name.

On the other spectrum there are names with multiple parts, usually including parents name, location names, generation name, caste name, and any new traditions people want to make up. Which parts should go into which field or column? First, middle, and last name could still work but would be up to the user to decide. The problem with that is that we lose some capabilities to easily group people by names... but is that really a problem?

Along the same line, many east and southern Asian names are family names first. Should that be literally the first name or switch the family name  to the last name? This also poses the same problem as many immigrants decades ago have adapted their names to the given name then family name structure, while more current immigrants have kept the same order (like Yao Ming).

At the end of the day, is there a real need to separate the name into first, middle, and last? As the w3 site suggests, I could use different fields of full name, given name, and/or display name. I would lose the ability the ability to automate the US American formality of addressing names as Mr., Mrs., or Ms, as I wouldn't know what the last name is (because some last names have multiple parts).


Reference
http://www.w3.org/International/questions/qa-personal-names