Jeff H's Profile User Rating: -----

Reputation: 112 Stalwart
Group:
Active Members
Active Posts:
309 (0.19 per day)
Joined:
30-January 11
Profile Views:
3,754
Last Active:
User is offline Jun 19 2015 09:14 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Jeff H has not set their status

Posts I've Made

  1. In Topic: Method Complexity

    Posted 13 Aug 2014

    A little late but something not mentioned or to bring more attention to about TakeABreath example is its readability.


    Anyone person can only keep about 4 to 7 ideas or thoughts in their mind at one time.
    Breaking up methods into smaller parts that are not easily understood probably isn't any better.

    When you look at TakeABreath method it is easy to see that there 3 main parts inhale, process, exhale.
    There might be complex computations happening but, if all I need to know is call TakeABreath when a breath is needed that's it. If something changes and need to know what it does it is easily understood at a high level and do not require unnecessary information or noise to understand the lower level ideas.
    For example if need change the way oxygen is brought in I do not need to know about processing oxygen or exhaling to see to what happens when inhaling, or to put it another way it does not require having to understand, filter out, etc.. to see inhale implementation.


    Hopefully it makes sense but can you see how TakeABreath and its functions is close or organized to the way people naturally read or organize an idea? You appreciate code like that when scrolling up constantly because a method has 34 different local variables and it is 5th time you had to look because you can't remember what this one variable type is and that leads to some other class that constructor is just as bad.

    It has to happen somewhere but making code readable and broken up in way that makes it easy read is a very helpful skill.


    Not sure what your doing but might lend itself to CQS design.
    Not CQRS and the terminology has nothing to do with relational database.

    Quick overview is every method is a query or command.
    A query has NO side effects and returns a value. This could be value in private field etc..
    A command returns void and performs an action or changes state.

    A command can call a query but a query can not call a command.


    Also you can use functional programming concept of a "maybe" or in F# a maybe.
    Basically a collection constrained to having either 0 or 1 items instead of settings variables to null and null checks
  2. In Topic: need to count vowels in a string

    Posted 18 Sep 2013

    Not meant to be a correct a solution but no matter the problem always good to think of different approaches to see if better, validate another approach, look at problem differently, etc....

        class Program
        {
    
            static bool[] chars = new bool[126];
            static char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' };
    
            static Program()
            {
                foreach (var v in vowels)
                {
                    chars[(int)v] = true;
                }
            }
            static void Main(string[] args)
            {
    
                Console.WriteLine("Enter a string");
                string test = Console.ReadLine();
    
                PrintValue(test);
    
                Console.Read();
            }
    
            private static void PrintValue(string test)
            {
                int count = 0;
                foreach (var c in test)
                {
                    if (chars[(int)c])
                    {
                        Console.Write(c);
                        count++;
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
                Console.WriteLine("Total = {0}", count);
            }
        }
    
    

    Not sure how but what counting 'Y'?

My Information

Member Title:
D.I.C Regular
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

Page 1 of 1
  1. Photo

    rossypz Icon

    15 Aug 2014 - 01:43
    Hi,I Am Mrs Rose.I am writing to know you more for i have an important issue to discuss with you. for more details write me on This Email: rosse4u2006@hotmail.com wrte to my email..
    God bless.
    Roseline
  2. Photo

    Jeff H Icon

    14 Jul 2011 - 04:21
    To show it twice
  3. Photo

    Jeff H Icon

    14 Jul 2011 - 04:21
    To show it twice
  4. Photo

    Jeff H Icon

    13 Jul 2011 - 17:41
    Everything I do in my profile it does it twice.
  5. Photo

    Jeff H Icon

    13 Jul 2011 - 17:41
    Everything I do in my profile it does it twice.
  6. Photo

    raziel_ Icon

    13 Jul 2011 - 16:16
    lol i just saw your having fixo added twice in your friend list :D
  7. Photo

    Jeff H Icon

    09 Jul 2011 - 08:52
    Thanks smohd,
    and nice work yourself
  8. Photo

    smohd Icon

    03 Jul 2011 - 16:21
    Hi, nice work in VB.NET forum. keep it going :)
Page 1 of 1