Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under mvc...

aminbandeali says...

What is a Model View Controller (MVC) Framework?

MVC is a framework methodology that divides an application's implementation into three component roles: models, views, and controllers.

  • "Models" in a MVC based application are the components of the application that are responsible for maintaining state.  Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL).
  • "Views" in a MVC based application are the components responsible for displaying the application's user interface.  Typically this UI is created off of the model data (for example: we might create an Product "Edit" view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object).
  • "Controllers" in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI.  In a MVC application the view is only about displaying information - it is the controller that handles and responds to user input and interaction.

One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application.  Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.

The MVC pattern can also help enable red/green test driven development (TDD) - where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself.

Filed under: mvc

aanton says...

Filed under: mvc

Diego says...

Fat models are bad too.
...
In MVC, 'M' (Model) is the domain of business logic.
...
Business logic means logic specific to your business.
User authentication is not business logic.
Cloning records is not business logic.
Unless you're Google, search is not your business logic.
...
Anything that is generic [should not belong in Model.]

- Jonathan Dahl
Programming and Minimalism
(23 minutes into video)
http://www.infoq.com/presentations/dahl-programming-minimalism
(via Ryan Tomayko: http://tomayko.com/linkings/5503bdda5dd16343b615b4dfd9ab1e8c)

Filed under: mvc

WanCW says...

One of the great CSS tips I got from Zen of CSS was to put an id on the body tag of your html pages.  This makes it really easy to use one CSS file for your entire site (a optimization trick) and allow you to target elements on specific page easily without creating a lot of unnecessary content wrappers or bogey class names. 

It is also very simple thing to do on MVC sites. Using the convention of Controller+Action give an easy identifier (if you’re using areas or something else you will need to tweak this a little).

1. 替 body 加上 id,就可以全站共用一組 CSS 檔案。
2. Web Application 可以用 controllwe + action 作為 body 的 id。

Filed under: MVC

So, here it is. The first concept of my MVC (I am actually using it in the currentt development).

I have looked at many MVC frameworks and other derivates. A lot of them are very good, but a lot of them are also very extensive and require you to learn their framework usage. Having new naming conventions for certain common actions. I decided that I wanted a very, very simple and liteweight MVC which can be used unobtrusively. I have the first version at use. It is far from done, and I will be adding common features along the way, but as a proof of concept the MVC works. Plus, I can use PHP as I know it allready. So, inside the modeller I can use SQL the way I know it allready. This makes for very rapid development. Right now it weighs in at about: 16Kb.

Features that I will implement while I progress:
- User input validation
- SQL injection prevention
- Session handling

Filed under: mvc

I have been looking through some new approaches towards MVC,mostly they are framework based for ease of development. It turns out that, although a lot of them are fairly good, some do take up some extra processing time and memory (a more extensive comparison test). Nonetheless, the approach is very interessting. Right now I am studying the logic and deciding wether or not to go with an existing framework/concept or write my own version to keep it really lean and litewight. Still, a topic to dive into if you are doing PHP development. At the moment I am very charmed by the tutorial over at phpro.org on MVC.

Filed under: mvc

Alec says...

Last week I set out to learn PyGTK by doing. Quickly. As can be imagined, the resulting code was less than stellar, but I did learn a lot.

By far the most glaring design error I made was in not completely decoupling my UI objects from "business" logic, ala MVC. This failure was the result of not totally comprehending the role signals should play in GTK applications. I made the first step correctly, with distinct objects for the UI panel and logic, but sadly that was the last smart choice I made. My next was deciding how to update the UI when the state of the system changed. "Hmm", I thought. "If I just pass the appropriate UI control through to the logic layer, I can update the view as necessary! Brilliant!". BZzzzzzzzzzzzt! Wrong.

The right approach in GTK is to use signals to notify the UI of changes to your objects. To do this, inherit from gobject.Gobject and add a __gsignals__ attribute. Here's a mocked up example of a simulation that emits a "simulation-step" signal every time the simulation is updated. To update a hypothetical counter widget we simply connect the signal to a callback that updates the widget.

class Controller(gobject.GObject):
  __gsignals__ = {
    'simulation-step': (gobject.SIGNAL_RUN_FIRST,
                        gobject.TYPE_NONE, (int,)),
  }

  def step_simulation(self, step):
    self.emit('simulation-step', step)

class View(object):
  def __init__(self, builder, controller):
    # "builder" is a Glade gtk.Builder object.
    builder.connect_signals(self)
    self.step_counter = builder.get_object('step_counter')
    controller.connect('simulation-step', self.on_simulation_step)

  def on_simulation_step(self, simulation, step):
    self.step_counter.set_value(step)

controller = Controller()
view = View(controller)


The fundamental mistake I made was assuming that GTK signals were purely for notifying my application of UI changes. In reality, signals are equally important in notifying the UI of application state changes.

Filed under: mvc