Results 1 to 12 of 12
Like Tree3Likes
  • 1 Post By wwjd_kilden
  • 1 Post By notmyown
  • 1 Post By EarnestQ

User2User Tech Support

Get or give free technical support on using Christian Chat -- or any computer-related problems/questions!

Thread: MVC (Model-View-Controller)

  1. #1
    Senior Member wwjd_kilden's Avatar
    Join Date
    June 13th, 2009
    Age
    32
    Posts
    34,360
    Rep Power
    113

    Default MVC (Model-View-Controller)

    Hi.
    I haven't been doing much of this so I am still trying to wrap my mind around what belongs where.

    For now I have a view class with a dataGridView that is bound to a dataset , a controller, and a model which connects to a database, and I am able to display data (yay!).

    Now let's say I want to let the user be able to add a row of data to the database...

    How much of the job should the view class actually do?
    Should I have it create a datarow and pass it on,
    or do I send a string/ array something else via the controller and let only the model class worry about datarows?
    NEW? Genral help :Tech support : Prayer requests

    (Agus) tha mi a' dèanamh gàirdeachas thairis ort le seinn - Sephaniah 3:17

  2. #2
    Senior Member wwjd_kilden's Avatar
    Join Date
    June 13th, 2009
    Age
    32
    Posts
    34,360
    Rep Power
    113

    Default Re: MVC (Model-View-Controller)

    edit: or will editing the datagridview automatically edit the datset so I can just update the database with the dataadapter?

  3. #3
    Senior Member blue_ladybug's Avatar
    Join Date
    February 21st, 2014
    Age
    46
    Posts
    51,103
    Blog Entries
    8
    Rep Power
    212

    Default Re: MVC (Model-View-Controller)

    Ummmmmm... I got nothing.. lol





    Quote Originally Posted by pottersclay View Post
    Blue_ladybug is innocent, as we know in scripture " all people who like orange tabbies are innocent."
    Quote Originally Posted by blue_ladybug View Post
    LOL.. I'll use that defense the next time I get accused of something.. lol


    To read my cancer, depression, physical pain & suicide testimonies, go to the Blog tab in my profile.



  4. #4
    Junior Member Reformed_Goth's Avatar
    Join Date
    May 4th, 2014
    Age
    30
    Posts
    2
    Blog Entries
    1
    Rep Power
    0

    Default Re: MVC (Model-View-Controller)

    Hey wwjd_kilden:

    From what I've gathered, you want to have as little logic as possible in your view. This is to make your logic unit testable. Otherwise, you would need to do integration testing with Selenium and those tests take a long time to work.

    Also, this type of question belongs on StackOverflow more than here. The tech support forum is more in regards to the site rather than development work. Go there, if you haven't already, and a lot more people will be able to give you the help you need.

    Good luck!

  5. #5
    Senior Member wwjd_kilden's Avatar
    Join Date
    June 13th, 2009
    Age
    32
    Posts
    34,360
    Rep Power
    113

    Default Re: MVC (Model-View-Controller)

    it is for any tech related problems we have, at least that is how it has been used the years the section has existed

    I've tried stackoverflow before, all they will tell me is something along the lines of "why didn't you google it" or "why don't you already know how to do this noob?"
    blue_ladybug likes this.

  6. #6
    Senior Member JasonNosneh's Avatar
    Join Date
    August 2nd, 2015
    Age
    33
    Posts
    104
    Blog Entries
    3
    Rep Power
    2

    Default Re: MVC (Model-View-Controller)

    The reason they tell you to google it is because your questions are too vague and also you don't show relevant code. You don't even state what language you are using. MVC is just design pattern nothing more so it could be any language.

    The point of MVC is to have separation of concerns -- the view should only be responsible for what the user sees and include no business logic or database queries. The controller handles executing business logic from actions initiated by the user. The model is typically just a plain object that provides structure for the data. To retrieve data, query the database and convert the data into an instance of a model and in the view use the model to display the data to the user, and similarly, posted data by the user would be converted into the model and then the model would be converted into queries for modifying the database.

    A lot of people are ditching MVC frameworks such as ASP.NET MVC because creating models, server-side rendering in view, and all the other boiler plate required can be cumbersome and not best practice. Most people are building purely Javascript, Html, and CSS front-ends using frameworks like angularJS, ReactJS, Vue, etc. On the server-side using any language, just create a Web API that handles JSON response and requests. The is good because you can create one API that can be consumed by any device -- browser, app, desktop, etc.

  7. #7
    Senior Member wwjd_kilden's Avatar
    Join Date
    June 13th, 2009
    Age
    32
    Posts
    34,360
    Rep Power
    113

    Default Re: MVC (Model-View-Controller)

    I didn't provide code because my question wasn't about language specific code, but merely at what point to turn my data into database "format" (which I believe has little to do with what language I use). So thanks for answering that -


    The problem is in Norway people are doing all kinds of things in a lovely tangle
    (well, at least judging by what they say you must know in the IT job ads). Some of them actually specify MVC knowledge as a requrement, so I am just trying to get a hang of the basic idea of it, and half the guides out there are just as vague as my question

  8. #8
    Senior Member notmyown's Avatar
    Join Date
    May 26th, 2016
    Age
    57
    Posts
    1,681
    Rep Power
    72

    Default Re: MVC (Model-View-Controller)

    Quote Originally Posted by Reformed_Goth View Post
    Hey wwjd_kilden:

    From what I've gathered, you want to have as little logic as possible in your view. This is to make your logic unit testable. Otherwise, you would need to do integration testing with Selenium and those tests take a long time to work.

    Also, this type of question belongs on StackOverflow more than here. The tech support forum is more in regards to the site rather than development work. Go there, if you haven't already, and a lot more people will be able to give you the help you need.

    Good luck!
    this is my life story. lol!

    and yes, i comprehend you're not using the word 'logic' in the way i mean it.

    but just barely
    wwjd_kilden likes this.

  9. #9
    Senior Member EarnestQ's Avatar
    Join Date
    April 28th, 2016
    Age
    60
    Posts
    756
    Rep Power
    29

    Default Re: MVC (Model-View-Controller)

    I agree that the question is vague, and even though you are asking a "generic" question, providing the code may be helpful, because the answer may be language related. One language may provide methods and objects that work better than a different language at solving your question.

    However, if I understand you correctly, you are just experimenting, so why not do it both ways and see which way seems more elegant to you?

    There might also be some libraries out there where others have already solved the problem.
    wwjd_kilden likes this.
    The best way to help others understand and experience God's love better is to understand and experience it better yourself.

    Understanding and experiencing God's love better everyday is the most important task for anyone who considers him/herself to be a Christian.


    Love without truth is deception. Truth without love is arrogance. God's love and God's truth balanced is God's wisdom.

    The more one promotes himself and/or his ideas, the less he cares about eternal life for others.

  10. #10
    Senior Member wwjd_kilden's Avatar
    Join Date
    June 13th, 2009
    Age
    32
    Posts
    34,360
    Rep Power
    113

    Default Re: MVC (Model-View-Controller)

    Okai. I ditched what I was originally thinking of and started a new approach,
    since what I originally view is a mix of several tables, I think it would turn chaotic to let the user add a new row
    so now I am working on generating fields in a separate form to let the user enter info into a given table.

    I will probably write myself into a corner and return with some code

  11. #11
    Senior Member breno785au's Avatar
    Join Date
    July 23rd, 2013
    Age
    32
    Posts
    4,543
    Rep Power
    60

    Default Re: MVC (Model-View-Controller)

    Quote Originally Posted by wwjd_kilden View Post
    it is for any tech related problems we have, at least that is how it has been used the years the section has existed

    I've tried stackoverflow before, all they will tell me is something along the lines of "why didn't you google it" or "why don't you already know how to do this noob?"
    I'm surprised you got that result from stackoverflow. People there are usually pretty helpful.
    So many try to qualify the promises that I've made
    To twist the gift into some kind of trade
    But grace bears no allowance
    For your works to make your way
    Be not afraid
    Your price is paid

    ​​Around the world and back - Theocracy

  12. #12
    Senior Member wwjd_kilden's Avatar
    Join Date
    June 13th, 2009
    Age
    32
    Posts
    34,360
    Rep Power
    113

    Default Re: MVC (Model-View-Controller)

    Ok, for now I ended up sending the data as a list of strings.

    Here is a new question: I only recently found out you can actually load the schema information from the database into the dataset, so I am trying that out now (using C# and mysql):

    ----
    da.Fill(ds, tablename);
    da.FillSchema(ds, SchemaType.Source, tablename);
    ---

    Once I get to the point where I try to add a row to my dataset, and then the database, what difference does the added constraints make? - Will my code throw an exception when I try to add the row to my dataset table or what happens compared to if I don't bother adding the restraints?

    (The fieldlist is a list of strings containing whatever info the user inputted that is to go into the relevant table in the database)

    internal void updateDB(List<string> fieldList, string tablename)
    {
    throw new NotImplementedException();

    /*
    DataRow row = ds.Tables[tablename].NewRow();

    row["colname"] = stufffromlist;
    (...)

    ds.Tables[tablename].Rows.Add(row);
    da.Update(ds);
    */
    }

Similar Threads

  1. Man vs women from mans view and the biblical view
    By Blain in forum Bible Discussion Forum
    Replies: 3
    Last Post: May 27th, 2015, 06:06 PM
  2. Replies: 65
    Last Post: May 26th, 2015, 10:41 AM
  3. Spiritual Vision Model and New Creation Model
    By StoneThrower in forum Bible Discussion Forum
    Replies: 1
    Last Post: July 2nd, 2014, 09:52 PM
  4. Bi-Polar Controller
    By DyingDaily in forum Christian Poems & Poetry
    Replies: 0
    Last Post: January 8th, 2014, 04:20 PM
  5. To be a Christian Model?
    By wing2x in forum Christian Teens Forum
    Replies: 2
    Last Post: September 24th, 2011, 04:47 PM