Jump to content

  • Log In with Google      Sign In   
  • Create Account


Alpha_ProgDes

Member Since 05 Jul 2002
Offline Last Active Jul 20 2014 04:56 PM
***--

#5152867 Game Design for VR Devices

Posted by Alpha_ProgDes on 11 May 2014 - 09:02 AM

The VR headset, IIUC, are just fancy 3D glasses. So I don't think that anything particularly unique has to be done from a game design perspective. However, if a game designer is truly looking for VR experience than that would be more dependent on the hardware involved.


#5152722 Four pillars of object oriented programming

Posted by Alpha_ProgDes on 10 May 2014 - 12:42 PM

Somehow it seems I became the villain of OOP laugh.png
 

OK, I got it:
 
5 pillars of OOP:

  • encapsulation
  • inheritance
  • composition
  • abstraction
  • polymorphism
5 pillars of OOD:
  • Single Responsiblity
  • Open-Closed
  • Liskov Substitution
  • Interface Segregation
  • Dependency Injection
Got it.

So if I write a program, in order for it to be OOP, I must use all of encapsulation, inheritance, composition, abstraction, and polymorphism. If for any reason I do not include any one of those features, my program is not OOP compliant. As long as I include all of those features, my program is 100% OOP and the gods of OOP are satisfied.
 
Similarly, if I use all the features (or do not use all the features) of the second set, my design is similarly satisfying the deities of OOD.
 
For some reason, that doesn't sit well with me.
 
There are lots of programming languages that don't support all of the first five language items, and yet people seem satisfied that they can be used for object oriented programming.
 
The design pillars are generally good principles of design for object oriented programs, but are you suggesting that if I give a class more than one responsibility it suddenly ceases to be object oriented? If my interfaces are not completely segregated, my design ceases to be object oriented? I don't think so.
 
 
These are paradigms and general principles, not stone-etched laws.
 
Object oriented is a term from the 1960s, used to differentiate from other practices of using memory. There are many other data-centric ways to process data. Lots of stream-based and DSP-based algorithms work better without discretizing the data. And that's okay too.

 
When did I suggest anything? Or even make the implication that you think that I'm suggesting something? Are you railing against me or the overall concept of pillars of OOP/OOD?
 

inheritance

 
If you drop that one, you'll be back to four pillars.
 
I really don't know why anyone considers inheritance to be relevant to OOP. It's largely an artefact of a couple of common implementations (i.e. C++) that do not terribly rigorously follow OOP principles.
 
Now if you change it to interface inheritance, we'll be on the same page.


Well interface inheritance falls under the category of inheritance. With that said, I'm just trying to sort what is OOP and what is OOD as far as the so-called pillars go.


#5152644 Four pillars of object oriented programming

Posted by Alpha_ProgDes on 09 May 2014 - 11:31 PM

OK, I got it:

 

5 pillars of OOP:

  • encapsulation
  • inheritance
  • composition
  • abstraction
  • polymorphism

 

5 pillars of OOD:

  • Single Responsiblity
  • Open-Closed
  • Liskov Substitution
  • Interface Segregation
  • Dependency Injection



#5152574 Four pillars of object oriented programming

Posted by Alpha_ProgDes on 09 May 2014 - 12:41 PM


But I always say, "Composition, inheritance, abstraction, and polymoprhism." I don't replace encapsilation... I don't even know what's real...

 

Actually, I was saying: encapsulation, composition, abstraction, and polymorphism :)

 

But I was under the impression that the pillars of OOP was SOLID. I guess I was wrong :|




#5152571 Four pillars of object oriented programming

Posted by Alpha_ProgDes on 09 May 2014 - 12:23 PM

Should Pillar #2 be Composition ?




#5149083 Can someone give me a quick code review for HTML5 site?

Posted by Alpha_ProgDes on 23 April 2014 - 06:49 PM

It started just as "ASP.NET Empty Web Site". No Webforms, no MVC. I attempted to put the files and the code in a MVC like organization. But as I noted in the OP I didn't want the magic. Everything is hand coded.

 

You should be able to create an empty web site and just copy the files as is in there.




#5148430 Can someone give me a quick code review for HTML5 site?

Posted by Alpha_ProgDes on 20 April 2014 - 05:52 PM

Mainpage.cs
 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    
    /// <summary>
    /// Summary description for Mainpage
    /// </summary>
    ///
    namespace Models
    {
        public class Mainpage
        {
            private SqlConnection sqlConn;
            private string connStr;
            
            public Mainpage()
            {
                //
                // TODO: Add constructor logic here
                //
            }
    
            private void sqlInit()
            {
                connStr = ConfigurationManager.ConnectionStrings["TestInput"].ConnectionString;
                sqlConn = new SqlConnection(connStr);
            }
    
            public Mainpage(int id, string ld, DateTime? dm, string op1, string op2)
            {
                ID = id;
                LineDesc = ld;
                DateMade = dm;
                Options1 = op1;
                Options2 = op2;
            }
    
            public int ID { get; set; }
            public string LineDesc { get; set; }
            public DateTime? DateMade { get; set; }
            public string Options1 { get; set; }
            public string Options2 { get; set; }
    
            public void Save()
            {
                sqlInit();
                string insertStr = "usr_InsertValues";
                SqlCommand sqlCmd = new SqlCommand(insertStr, sqlConn);
                sqlCmd.CommandType = CommandType.StoredProcedure;
    
                SqlParameter sp;
                if (DateMade.HasValue)
                    sp = new SqlParameter("@p2", DateMade.Value);
                else
                    sp = new SqlParameter("@p2", DBNull.Value);
    
                SqlParameter[] sps = new SqlParameter[] {new SqlParameter("@p1", LineDesc),
                                                         sp,
                                                         new SqlParameter("@p3", Options1),
                                                         new SqlParameter("@p4", Options2)};
                sqlCmd.Parameters.AddRange(sps);
                
                sqlConn.Open();
                sqlCmd.ExecuteNonQuery();
                sqlConn.Close();
            }
        }
    }


Default.cs (ViewModel)
 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    /// <summary>
    /// Summary description for Default
    /// </summary>
    ///
    namespace ViewModels
    {
        public class Default
        {
    
            public Default()
            {
                //
                // TODO: Add constructor logic here
                //
            }
    
            public Default(string desc, string sop1, string sop2, string sop3)
            {
                Description = desc;
                SelectedOp1 = sop1;
                SelectedOp2 = sop2;
                SelectedOp3 = sop3;
            }
    
            public string Description { get; set; }
            public string SelectedOp1 { get; set; }
            public string SelectedOp2 { get; set; }
            public string SelectedOp3 { get; set; }
            public List<string> Option1 { get; set; }
            public List<string> Option2 { get; set; }
            public List<string> Option3 { get; set; }
    
            public void Save()
            {
                Models.Mainpage mp = new Models.Mainpage(0, Description, new DateTime?(DateTime.Now), SelectedOp1, SelectedOp2);
                mp.Save();
            }
        }
    }



Default.cshtml (Controller/Code behind)
 

    @{
        var linedesc = Request.Form["linedesc"];
        var datemade = DateTime.Now.ToString();
        var food = Request.Form["options1"];
        var drinks = Request.Form["options2"];
        
        string[] data = new String[4] {linedesc, datemade, food, drinks};
        
        // Go back to Default.html and keep values selected, ie. values don't reset
        var blah = "hi";
    
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
            
        if (IsPost)
        {
            ViewModels.Default vm = new ViewModels.Default(linedesc, food, drinks, null);
            vm.Save();
        }
        Json.Write(data, Response.Output);
        
    }


Default.html (View)

 

   <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Testing Stuff</title>
        <script type="text/javascript" src="/Views/JS/jquery-2.0.3.js"></script>
        <script type="text/javascript" src="/Views/JS/Default.js"></script>
    </head>
    <body>
        <form id="mainpage" method="post" action="../Controllers/Default">
            <div style="clear:both;" id="dbInput">
                <label for="linedesc">Description:</label>&nbsp;
                <input type="text" id="linedesc" name="linedesc" />
    
                <br /><br />
    
                <input id="fruits" name="options1" value="fruits" type="radio" />
                <label for="fruits">Fruits</label>&nbsp;
                <input id="candies" name="options1" value="candies" type="radio" />
                <label for="candies">Candies</label>&nbsp;
                <input id="snacks" name="options1" value="snacks" type="radio" />
                <label for="snacks">Snacks</label>
    
                <br /><br />
    
                <label for="options2">Choose beverage:</label>&nbsp;
                 <select id="options2" name="options2">
                    <option value="Coca-Cola">Coca-Cola</option>
                    <option value="Sprite">Sprite</option>
                    <option value="Root Beer">Root Beer</option>
                    <option value="Orange Juice">Orange Juice</option>
                </select>
    
                <br /><br />
    
                <label for="options3">Sample:</label>&nbsp;
                <select id="options3" name="options3">
    
                </select>
    
                <input type="submit" id="submit1" name="submit1" value="Submit" />
            </div>
        </form>
    </body>
    </html>

Default.js (JavaScript)

 

   $(document).ready(function () {
        //$('#submitText').click(function () {
        // $('#txtHolder').html('<span>I am like code behind in txtHolder.</span>');
        // $('#results').html('<span>Results are here today.</span>');
        //});
    
        $('#mainpage').submit(function (e) {
            e.preventDefault();
            alert("hi");
            var formData = $(this).serialize();
            var frm = $(e.target);
            $.ajax({
                url: "../../Controllers/Default.cshtml",
                data: formData,
                type: "POST",
                dataType: "json",
                success: function (response) {
                    alert(response);
                    var options3 = $("#options3");
                    options3.empty();
                    for (var i = 0; i < response.length; i++)
                    {
                        options3.append(
                            $("<option></option>").text(response[i]).val(response[i])
                        );
                    }
                    // Adds data to dropdown
                },
                error: function () {
                    alert("Sorry, there seems to be a problem contacting the server.");
                }
            });
        });
    });



#5148390 Can someone give me a quick code review for HTML5 site?

Posted by Alpha_ProgDes on 20 April 2014 - 12:47 PM

:(

 

No one?




#5148138 Can someone give me a quick code review for HTML5 site?

Posted by Alpha_ProgDes on 19 April 2014 - 08:29 AM

So basically, I'm trying to get a better handle of code organization and how HTML5 (really HTML) stack works in general. I've worked mostly with ASP.NET Webforms and done some MVC as well. Let me say now, "I hate magic". I hate figuring out the magic. I just want it to work in the manner that it's supposed to. That's why I'm using neither. I basically created an empty web site and added the files I needed. No more, no less.  So I posted this little HTML5 site on GitHub. Nothing fancy. At all.

 

However, I did structure the folders and files in a MVC-like way. And also I used razor/cshtml file to mimic code-behind. Completely separating the HTML from the server-side code. Also, the JQuery and Javascript is in its own file as well, again, completely separated from the HTML. I have one line of CSS in the HTML.

 

All I'm using is: HTML, Javascript, JQuery, no CSS, and CSHTML (as codebehind).

 

So in short, is this good? Is this bad? What could be better?

 

The link.

 

 

 

Note: If anyone wants to test it, all the files are on GitHub. Even the scripts to create the database. All anyone has to do is: create an empty web site in WebMatrix or Visual Studio. Download the project from GitHub and copy them straight into the website. Configuration files are already setup. All that has to be done is replace DB\DBExpress with the name of the actual database.




#5145984 What does the standard say about this?

Posted by Alpha_ProgDes on 10 April 2014 - 10:05 AM

Out of curiosity, should your first line be this:
 
    typedef std::array<std::uint32_t, 16> messagechunk_type;
    int Index = 0;
    const messagechunk_type ProcessBlock =
     
    {
     
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index]),  // <-- Since Index starts at 0
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //4
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //8
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //12
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //16
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //20
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //24
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //28
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //32
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //36
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //40
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //44
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //48
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //52
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index += sizeof(std::uint32_t)]), //56
        FromLittleEndian<std::uint32_t, CharArray::value_type>(&MessageBlock[Index]) //60
     
    };

And honestly, I think a for-loop would be far more readable. Unless you're unrolling the loop for performance reasons as well.


#5145387 I have some new habits.

Posted by Alpha_ProgDes on 08 April 2014 - 09:51 AM

If gravity is in a class, then all you would have to do is change parameters (variable values) to get real-world gravity and non-real-world gravity or something else entirely. If gravity is a function, then it's coupled to whatever class or game you're using. So you'll always have to change the function to suit whatever class or game you're making. So reuse is out the window.

Please someone correct me if I'm wrong.


#5145368 I have some new habits.

Posted by Alpha_ProgDes on 08 April 2014 - 09:17 AM

I've learned that OOP is bad when you don't understand OOP. In fact, lots of things are bad when you don't understand them.


For instance, explain why a gravity function would be more reusable than a gravity class?


#5145364 What it's like to be a software engineer (video)

Posted by Alpha_ProgDes on 08 April 2014 - 09:15 AM

All companies with an IT department should be forced to watch this video before every meeting.

This is so unfortunately funny. It hurts.


#5144156 Making an object in Javascript?

Posted by Alpha_ProgDes on 03 April 2014 - 11:42 AM

I know you can do something like this:

var obj = {stuff: 'blah', work: function foo () {return 1}; place: 'bar'};

But you can also do this, I believe:

var obj = function () 
          { 
             this.stuff = 'blah', 
             this.work = function foo () {return 1}, 
             this.place = 'bar'
          };

So is there a difference between creating an object with a function as opposed to object notation? When would I use one over the other?




#5142055 Javascript Memory leak

Posted by Alpha_ProgDes on 25 March 2014 - 12:43 PM

@Alpha

 

In javascript functions without a return statement return the value undefined.

 

Duh. **slaps head**, **then reminds self it ain't lisp**, **slaps head again**






PARTNERS