Search Results

Search found 1399 results on 56 pages for 'separation of concerns'.

Page 4/56 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • starting with flex - please let me know if the direction is right (ActionScript vs MXML separation)

    - by Piotr
    Hi, I've just started learning flex using OReilly "Programming Flex 3.0". After completing three chapters and starting fourth (ActionScript), and not having enough patience to wait till completing chapter 22 I started to practice :) One bit that I have most worries about right now is the the dual coding mode (MXML vs ActionScript) Please have a look at my code below (it compiles via mxmlc design.mxml, second file 'code.as' should be in same directory) and advise if the separation I used between visual design and code is appropriate. Also - if some smart guy could show me how to recode same example with *.as being a class file [package?] it would be highly appreciated. I got lost with creating directory structure for package - and did not find it most intuitive, especially for small project that has two files like my example. Code: design.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script source="code.as"/> <mx:VBox> <mx:TextInput creationComplete="initializeCalculator()" id="txtScreen"/> <mx:HBox> <mx:Button click="click('7')" id="btn7" label="7"/> <mx:Button click="click('8')" id="btn8" label="8"/> <mx:Button click="click('9')" id="btn9" label="9"/> <mx:Button click="click('C')" id="btnClear" label="C"/> </mx:HBox> <mx:HBox> <mx:Button click="click('4')" id="btn4" label="4"/> <mx:Button click="click('5')" id="btn5" label="5"/> <mx:Button click="click('6')" id="btn6" label="6"/> <mx:Button click="click('/')" id="btnDivide" label="/"/> </mx:HBox> <mx:HBox> <mx:Button click="click('1')" id="btn1" label="1"/> <mx:Button click="click('2')" id="btn2" label="2"/> <mx:Button click="click('3')" id="btn3" label="3"/> <mx:Button click="click('*')" id="btnMultiply" label="*"/> </mx:HBox> <mx:HBox> <mx:Button click="click('0')" id="btn0" label="0"/> <mx:Button click="click('=')" id="btnEqual" label="="/> <mx:Button click="click('-')" id="btnMinus" label="-"/> <mx:Button click="click('+')" id="btnPlus" label="+"/> </mx:HBox> </mx:VBox> </mx:Application> code: code.as public var res:int = 0; public var previousOperator:String = ""; public var previousRes:int=0; public function initializeCalculator():void{ txtScreen.text = res.toString(); } public function click(code:String):void{ if (code=="1" || code=="2" || code=="3" || code=="4" || code=="5" || code=="6" || code=="7" || code=="8" || code=="9" || code=="0"){ res = res*10 + int(code); txtScreen.text = res.toString(); } else if (code=="C"){ res = 0; previousOperator =""; previousRes = 0; txtScreen.text = res.toString(); } else{ calculate(code); } } public function calculate(operator:String):void{ var tmpRes:int; if (previousOperator=="+"){ tmpRes = previousRes + res; } else if (previousOperator=="-"){ tmpRes = previousRes - res; } else if (previousOperator=="/"){ tmpRes = previousRes / res; } else if (previousOperator=="*"){ tmpRes = previousRes * res; } else{ tmpRes = res; } previousOperator = operator; previousRes = tmpRes; txtScreen.text = previousRes.toString(); res = 0; if (previousOperator=="=") { res = tmpRes; txtScreen.text=res.toString(); } } PS. If you have comments that this calculator does not calculate properly, they are also appreciated, yet most important are comments on best practices in Flex.

    Read the article

  • Clean separation of UI with Caliburn MVVM

    - by sylvie
    Looking into various MVVM frameworks for SL. In the Caliburn documentation I saw a code in a controller that calls MessageBox. Is this right or is this just for intro? Is there something like MessageBox service in Caliburn like in Chinch MVVM?

    Read the article

  • How to fix RapidXML String ownership concerns?

    - by Roddy
    RapidXML is a fast, lightweight C++ XML DOM Parser, but it has some quirks. The worst of these to my mind is this: 3.2 Ownership Of Strings. Nodes and attributes produced by RapidXml do not own their name and value strings. They merely hold the pointers to them. This means you have to be careful when setting these values manually, by using xml_base::name(const Ch *) or xml_base::value(const Ch *) functions. Care must be taken to ensure that lifetime of the string passed is at least as long as lifetime of the node/attribute. The easiest way to achieve it is to allocate the string from memory_pool owned by the document. Use memory_pool::allocate_string() function for this purpose. Now, I understand it's done this way for speed, but this feels like an car crash waiting to happen. The following code looks innocuous but 'name' and 'value' are out of scope when foo returns, so the doc is undefined. void foo() { char name[]="Name"; char value[]="Value"; doc.append_node(doc.allocate_node(node_element, name, value)); } The suggestion of using allocate_string() as per manual works, but it's so easy to forget. Has anyone 'enhanced' RapidXML to avoid this issue?

    Read the article

  • SQL Server to PostgreSQL - Migration and design concerns

    - by youwhut
    Currently migrating from SQL Server to PostgreSQL and attempting to improve a couple of key areas on the way: I have an Articles table: CREATE TABLE [dbo].[Articles]( [server_ref] [int] NOT NULL, [article_ref] [int] NOT NULL, [article_title] [varchar](400) NOT NULL, [category_ref] [int] NOT NULL, [size] [bigint] NOT NULL ) Data (comma delimited text files) is dumped on the import server by ~500 (out of ~1000) servers on a daily basis. Importing: Indexes are disabled on the Articles table. For each dumped text file Data is BULK copied to a temporary table. Temporary table is updated. Old data for the server is dropped from the Articles table. Temporary table data is copied to Articles table. Temporary table dropped. Once this process is complete for all servers the indexes are built and the new database is copied to a web server. I am reasonably happy with this process but there is always room for improvement as I strive for a real-time (haha!) system. Is what I am doing correct? The Articles table contains ~500 million records and is expected to grow. Searching across this table is okay but could be better. i.e. SELECT * FROM Articles WHERE server_ref=33 AND article_title LIKE '%criteria%' has been satisfactory but I want to improve the speed of searching. Obviously the "LIKE" is my problem here. Suggestions? SELECT * FROM Articles WHERE article_title LIKE '%criteria%' is horrendous. Partitioning is a feature of SQL Server Enterprise but $$$ which is one of the many exciting prospects of PostgreSQL. What performance hit will be incurred for the import process (drop data, insert data) and building indexes? Will the database grow by a huge amount? The database currently stands at 200 GB and will grow. Copying this across the network is not ideal but it works. I am putting thought into changing the hardware structure of the system. The thought process of having an import server and a web server is so that the import server can do the dirty work (WITHOUT indexes) while the web server (WITH indexes) can present reports. Maybe reducing the system down to one server would work to skip the copying across the network stage. This one server would have two versions of the database: one with the indexes for delivering reports and the other without for importing new data. The databases would swap daily. Thoughts? This is a fantastic system, and believe it or not there is some method to my madness by giving it a big shake up. UPDATE: I am not looking for help with relational databases, but hoping to bounce ideas around with data warehouse experts.

    Read the article

  • Git for Websites / post-receive / Separation of Test and Production Sites

    - by Walt W
    Hi all, I'm using Git to manage my website's source code and deployment, and currently have the test and live sites running on the same box. Following this resource http://toroid.org/ams/git-website-howto originally, I came up with the following post-receive hook script to differentiate between pushes to my live site and pushes to my test site: while read ref do #echo "Ref updated:" #echo $ref -- would print something like example at top of file result=`echo $ref | gawk -F' ' '{ print $3 }'` if [ $result != "" ]; then echo "Branch found: " echo $result case $result in refs/heads/master ) git --work-tree=c:/temp/BLAH checkout -f master echo "Updated master" ;; refs/heads/testbranch ) git --work-tree=c:/temp/BLAH2 checkout -f testbranch echo "Updated testbranch" ;; * ) echo "No update known for $result" ;; esac fi done echo "Post-receive updates complete" However, I have doubts that this is actually safe :) I'm by no means a Git expert, but I am guessing that Git probably keeps track of the current checked-out branch head, and this approach probably has the potential to confuse it to no end. So a few questions: IS this safe? Would a better approach be to have my base repository be the test site repository (with corresponding working directory), and then have that repository push changes to a new live site repository, which has a corresponding working directory to the live site base? This would also allow me to move the production to a different server and keep the deployment chain intact. Is there something I'm missing? Is there a different, clean way to differentiate between test and production deployments when using Git for managing websites? As an additional note in light of Vi's answer, is there a good way to do this that would handle deletions without mucking with the file system much? Thank you, -Walt PS - The script I came up with for the multiple repos (and am using unless I hear better) is as follows: sitename=`basename \`pwd\`` while read ref do #echo "Ref updated:" #echo $ref -- would print something like example at top of file result=`echo $ref | gawk -F' ' '{ print $3 }'` if [ $result != "" ]; then echo "Branch found: " echo $result case $result in refs/heads/master ) git checkout -q -f master if [ $? -eq 0 ]; then echo "Test Site checked out properly" else echo "Failed to checkout test site!" fi ;; refs/heads/live-site ) git push -q ../Live/$sitename live-site:master if [ $? -eq 0 ]; then echo "Live Site received updates properly" else echo "Failed to push updates to Live Site" fi ;; * ) echo "No update known for $result" ;; esac fi done echo "Post-receive updates complete" And then the repo in ../Live/$sitename (these are "bare" repos with working trees added after init) has the basic post-receive: git checkout -f if [ $? -eq 0 ]; then echo "Live site `basename \`pwd\`` checked out successfully" else echo "Live site failed to checkout" fi

    Read the article

  • Concerns about reading a file in Flash 10

    - by user246114
    Hi, I'd like to read an xml file on a user's machine (which can be kind of large). There's no point in me sending the file to my server as I can do all the work I need on the file right on the client's machine. Not sure if this is a good fit though, was wondering if anyone can answer these questions before I dive in: I see at adobe's website that Flash 10 has like 94% penetration, is this true, I thought it was just released not too long ago? After opening the xml file in flash, is it possible to just throw it to a javascript function on my same page for further processing? I'd like to go into flash world for as short a time as possible. Is it at all common to use flash for file upload stuff? I heard aol/flickr are? I would need to buy flash in order to do this right, they don't have a free ide/compiler yet? Thanks

    Read the article

  • Architectural conundrum

    - by Dejan
    The worst thing when working on a one man project is the lack of input that you usually get from your coworkers. And because of the lack of that you tend to make obvious mistakes. After going down that road for some time I would need some help from the community. I started a little home-brew project that should turn into a portal of some sorts. And the main thing that is bothering me is the persistence layer that i have concocted. It should be completely separated from the presentation layer for starters and a OR mapper is also somewhere. This is because I have multiple data stores that have to be used. So the base idea was that the individual "repositories" operate each on their individual database and that the business layer then aggregates the business objects which are then transformed in the presentation layer into view objects. The main problem I face is the following: Multiple classes for the same concept - There is a DAL representation of a user and BL representation of user and a view representation of a user. I can handle the transformation with a tool but is this really the right way. I mean they are all nicely separated, but the overhead is quite something. What do you think? Am I going too deep into the separation of concern rabbit hole or is this still normal?

    Read the article

  • WPF Skin Skinning Security Concerns

    - by Erik Philips
    I'm really new to the WPF in the .Net Framework (get that out of the way). I'm writing an application where the interface is very customizable by simply loading .xaml (at the moment a Page element) files into a frame and then mapping the controls via names as needed. The idea is to have a community of people who are interested in making skins, skin my application however they want (much like Winamp). Now the question arises, due to my lack of Xaml knowledge, is it possible to create malicious Xaml pages that when downloaded and used could have other embedded Iframes or other elements that could have embed html or call remote webpages with malicious content? I believe this could be the case. If this is the case then I two options; either I have an automated process that can remove these types of Xaml files by checking it’s elements prior to allowing download (which I would assume would be most difficult) or have a human review them prior to download. Are there alternatives I’m unaware of that could make this whole process a lot easier?

    Read the article

  • Separation of logic from presentation: HTTP variable names?

    - by Allan Jardine
    Hello all, This could probably be considered an academic question, rather than a real world one - but throwing it out to see if anyone has any great ideas! We all know that keeping the business logic of an application separate from the presentation is a good idea (I'm looking at web-apps atm), but there needs to be an understanding between the business logic for what HTTP variables to expect (and then process) and the variable names which are sent by the presentation layer. Is this simply a matter of telling the designer what variable names to use in a template? The template doesn't need to know what the variable names are (unless using them for JS/CSS selectors), so why should they be 'hardcoded' in there. Or should the business logic put the names into variables to be printed out? Another layer of complexity for the templates? Does anyone have any experience of this, or thoughts on how to deal with it? Thanks, Allan

    Read the article

  • Windows azure: Security Concerns

    - by veda
    I am concern about the security of the data and application on Windows Azure... I read in a book that The windows azure provides security through service-level agreement. Can anyone tell me about the What kind of authentication mechanisms used to protect my data. How Microsoft provides these securities...

    Read the article

  • ASP.NET Membership and Roles separation relationship

    - by Saif Khan
    Hi, I have an ASP.NET project where I want to keep the membership (SQL Provider) in a separate database and the Roles/Profiles will be per application. Question What is the KEY that relates between the Membership database and the Roles/Profile database? Is it the UserID or UserName? I opened up the tables in separate expolrer and notice the UserID is different in the Membership database from that in the application Roles database.

    Read the article

  • Color separation in OpenCV?

    - by user225626
    Is there a function or a series of function steps that roughly equate to... get every pixel from myInput which doesn't meet an arbitrary Green quantity threshhold set each of those pixels to black on myOutput Thanks for any assistance.

    Read the article

  • Vim 80 column layout concerns

    - by cdleary
    I feel like the way I do 80-column indication in Vim is incorrect: set columns=80. At times I also set textwidth but I like to be able to see and anticipate line overflow with the set columns alternative. This has some unfortunate side effects -- I can't set number for fear of splitting between files that have different orders of line numbers; i.e. < 100 line files and = 100 line files will require two different set columns values because of the extra column used for the additional digit display. I also start new (g)Vim sessions instead of splitting windows vertically, which forces me to use the window manager's clipboard -- vsplits force me to do set columns every time I open or close a pane, so starting a new session is less hassle. How do you handle the 80-character indication when you want to set numbers, vertically split, etc.?

    Read the article

  • Security concerns for a multi-language site.

    - by The Rook
    I am converting a PHP MySQL web application written for English language into a Multi-Language site. Do you know any vulnerabilities that affect web applications in another language? Or perhaps vulnerabilities that could be introduced in the conversion of code base to support multiple languages. (If you know any vulnerabilities of this type in another language I'll give you a +1)

    Read the article

  • Modular GWT design concerns

    - by GlGuru
    Hi, I have a couple of questions regarding a modular GWT based application framework. I have some ideas about them but being new to the field of web development I feel they are far from ideal. I'd appreciate a few comments and suggestions in this regard. Here are my questions: I am developing a framework which will allow third parties to embed GWT applications into our website and do some communication with them using simple iFrame postMessage. All these third party modules are going to use our SDK which is also GWT based. The problem arises that even though all the modules will be using the same codebase there is going to be a massive overheard in the amount of duplicate Javascript code (i.e. our common SDK code base which is quite large) being downloaded on the client's machine. This is highly redundant and problematic, not only due to the sheer size of duplicate code but, also due to the fact that subsequent updates of the SDK would require the modules to be recompiled which is going to create a DLL hell kind of scenario in the long run. What is the best way of doing this kind of thing? Is there a way where I can have some static GWT code (i.e. the SDK) and the dynamic GWT module refers to it (even if lies on a different domain) and it all work happily? The other part of the problem lies in providing robust scripting front end to the SDK. At first it appears to be trivial since Javascript itself is a scripting language. However, I do not know how to load and call a piece of pure Javascript code at runtime? I am willing to put restrictions on the target Javascript (i.e. having a function main and unique namespace or something). Furthermore the Javascript will come as a string from a database and not as a full URL. If its doable in Javascript how does one get this right in GWT i.e. forcing the compiler to emit a certain function in the generated Javascript? This I believe can be lesser of a problem by having a stub Javascript with all the right requirements which just loads up a GWT generated Javascript. Is any of this possible at all? I generally hate to be this verbose but I hope to find a quick solution to the problem as its holding up my progress. I'd highly appreciate any comments, suggestions and experiences.

    Read the article

  • another onmouseover problem this one concerns pictures

    - by user334118
    Hi all! have problems with mouseover in Mozilla and Chrome after making it work in IE, for sure I can tell you that my code woked perfectly in Chrome at least, cause thats my default browser and I used it for debuging when creating the javascipt and it worked nicely... until I tried to make it work in IE too. Here I post the full code of the webpage I'm having trouble with. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebbShop.aspx.cs" Inherits="FSwebportal.WebbShop" %> .prodShow{width: 100%; text-align:center;border:0; float:right; position:inherit; padding-left:310px;} prodFollow{display:block; width:100%; height:100%; position:fixed; overflow:hidden;} orderSett{display:block; position:relative; float:left; padding-top:inherit;} .ShowBig{width:290px;height:290px; padding-top:10px;} .pTb{width:50px;} .order{background-color:Transparent;margin:3px;} .txtArea{border:0;overflow:auto;width:200px;height:100px;} .prodRow{background-image:url("produktbakgrund.png"); background-repeat:repeat;} .row{background-color:Transparent;width:100%;margin: 0px auto;display:inline-table;} .col{background-color:Transparent;width:100%;margin:3px;} <div id="prodFollow"> <table id="dumbTable"> <tr> <td> <img id="sideImg" class="ShowBig" src="" alt=""/> </td> </tr> <tr> <td> <h3><b>Specifikationer:</b></h3> <select name=""> </select> </td> </tr> </table> </div> <table id="itemList" class="prodShow" cellspacing="0"> <thead> <tr class="prodRow"> <th>Bild</th> <th>Förklaring</th> <th>Artikelnummer</th> <th>Pris</th> </tr> </thead> </table> <script type="text/javascript"> function appendRow() { var tbl = document.getElementById('itemList'); var len = <%= aspInfo.Count %>; var arr = new Array(len); var currIndex = 0; var imgID=0; <% for (int x = 0; x < aspInfo.Count; x++) { Response.Write("arr["+x+"]= '"+ aspInfo[x]+"';"); } %> for(row =0; row < arr.length/4;row++) { var rad = tbl.insertRow(tbl.rows.length); rad.setAttribute('class','prodRow'); for (c = 0; c < tbl.rows[row].cells.length; c++) { if(c < 1) { createCell(rad.insertCell(c), arr[currIndex], 'col',imgID); imgID++; } else { if(c < 3) { createCell(rad.insertCell(c),"<Label class=txtArea>" + arr[currIndex] + "</Label>", 'row',imgID); } else { createCell(rad.insertCell(c),"<Label class=txtArea>" + arr[currIndex] + " SKR</Label><br>Antal:<input type=text class=pTb /><input type=button width=100px value='Lägg i varukorg'></input>", 'order',imgID); } } currIndex++; } } } function createCell(cell, text, style,imgID) { if (style == 'col') { var arrLen = <% = largeImg.Count %>; var imgArr = new Array(arrLen); <% for (int x = 0; x < largeImg.Count; x++) { Response.Write("imgArr["+x+"]= '"+ largeImg[x]+"';"); } %> var div = document.createElement('div'); div.setAttribute('class', style); div.setAttribute('className', style); div.innerHTML = "<a href='#'><img id='" + imgID + "' src='" + text + "' onmouseover=javascript:onImg('" + imgArr[imgID] + "') border='0' alt='Animg' /></a>"; cell.appendChild(div); } else { var div = document.createElement('div'); div.setAttribute('class', style); div.setAttribute('className', style); div.innerHTML = text; cell.appendChild(div); } } </script> <script type="text/javascript" language="javascript"> function onImg(bigImg) { var img = document.getElementById('sideImg#'); img.src = bigImg; alert(img.src.toString()); } </script> </form> hope you guys can solve it for me, going mad! best regards David

    Read the article

  • Lua and C++: separation of duties

    - by topright
    Please hel to classify ways of organizing C++/Lua game code and to separate their duties. What are the most convenient ways, which one do you use? For example, Lua can be used for initializing C++ objects only or at every game loop iteration. It can be used for game logic only or for graphics, too. Thank you.

    Read the article

  • SSRS Multilookup Function for Names with Comma Separation

    - by AliceAyers292
    I would like to put the following in a a multilookup drop-down in reporting services: "Smith, John", "Jones, Tim", "Kelly, Andy" The comma separating the first and last name prevents the multilookup from working correctly. I am also unable to use ticks (' or ") in reporting service to keep the separating comma from working like a multilookup comma that separates the fields I want to select from. Is there a way to keep the comma in the names while still allowing multilookup? Any help would be much appreciated. Thank you!

    Read the article

  • Decoupling into DAL and BLL - my concerns.

    - by novice_man
    Hi, In many posts concerning this topic I come across very simple examples that do not answer my question. Let's say a have a document table and user table. In DAL written in ADO.NET i have a method to retries all documents for some criteria. Now I the UI I have a case where I need to show this list along with the names of the creator. Up to know I have it done with one method in DAL containig JOIN statement. However eveytime I have such a complex method i have to do custom mapping to some object that doesn't mark 1:1 to DB. Should it be put into another layer ? If so then I will have to resing from join query for iteration through results and querying each document author. . . which doen't make sense... (performance) what is the best approach for such scenarios ?

    Read the article

  • Separation of static and dynamic content in Java EE applications

    - by Dan
    We work with IBM products and we typically use IBM Http Servers (read Apache) as a reverse proxy for our application servers. For performance reasons we serve static content (.gif, .jpg, .css, .html etc.) from our http servers, to ease the burden a bit from the application server. So far, we have to distribute files to http server and configure it manually (writing custom scripts at best.) The problem is the effort needed to keep everything in synch, especially when you need to update the app. Does any Java EE product support this “out of the box”? Is there a way to have application server do this automatically, like in cluster configuration for example, where master node is in charge of distributing the application to other nodes and for keeping everything in synch.

    Read the article

  • getSharedPreferences not working for me with concerns to ListPreferences and Integers

    - by ideagent
    I'm stuck at a point where I'm trying to get my project to read a preference value (from a ListPreference listing) and then use that value in a basic mathematical subtraction instance. The problem is that the "seek" preference is not being seen by my Java code, and yet the default value is (I've tried the default value with 3000 and now 0). Am i missing something, is there a bug here, known or unknown? Java code chunk where the issues manifests itself: public static final String PREF_FILE_NAME = "preferences"; seekback.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View view) { try { SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE); Integer storedPreference = preferences.getInt("seek", 0); (mediaPlayer.getCurrentPosition()-storedPreference); } catch (Exception e) { e.printStackTrace(); } } }); Here are some other code bits for my project: From preferences file: <ListPreference android:entries="@array/seconds" android:entryValues="@array/seconds_values" android:summary="sets the seek interval for the seekback and seekforward buttons" android:title="Seek Interval" android:defaultValue="5000" android:key="@string/seek" From strings file: seek From an array file: Five seconds Fifteen seconds Thirty seconds Sixty seconds 5000 15000 30000 60000 let me know if you need to see more code to figure this one out Thanks in advance for any help that can be offered. I've worked over this issue now for a few hours and I'm burnt, a second pair of eyes on it would be very much appreciated. Arg, not sure how to get the code and plain text to format nicely here, even tried the options, like Code Sample, no luck AndroidCoder

    Read the article

  • Separation of presentation and business logic in PHP

    - by Markus Ossi
    I am programming my first real PHP website and am wondering how to make my code more readable to myself. The reference book I am using is PHP and MySQL Web Development 4th ed. The aforementioned book gives three approaches to separating logic and content: include files function or class API template system I haven't chosen any of these yet, as wrapping my brains around these concepts is taking some time. However, my code has become some hybrid of the first two as I am just copy-pasting away here and modifying as I go. On presentation side, all of my pages have these common elements: header, top navigation, sidebar navigation, content, right sidebar and footer. The function-based examples in the book suggest that I could have these display functions that handle all the presentation example. So, my page code will be like this: display_header(); display_navigation(); display_content(); display_footer(); However, I don't like this because the examples in the book have these print statements with HTML and PHP mixed up like this: echo "<tr bgcolor=\"".$color."\"><td><a href=\"".$url."\">" ... I would rather like to have HTML with some PHP in the middle, not the other way round. I am thinking of making my pages so that at the beginning of my page, I will fetch all the data from database and put it in arrays. I will also get the data for variables. If there are any errors in any of these processes, I will put them into error strings. Then, at the HTML code, I will loop through these arrays using foreach and display the content. In some cases, there will be some variables that will be shown. If there is an error variable that is set, I will display that at the proper position. (As a side note: The thing I do not understand is that in most example code, if some database query or whatnot gives an error, there is always: else echo 'Error'; This baffles me, because when the example code gives an error, it is sometimes echoed out even before the HTML has started...) For people who have used ASP.NET, I have gotten somewhat used to the code-behind files and lblError and I am trying to do something similar here. The thing I haven't figured out is how could I do this "do logic first, then presentation" thing so that I would not have to replicate for example the navigation logic and navigation presentation in all of the pages. Should I do some include files or could I use functions here but a little bit differently? Are there any good articles where these "styles" of separating presentation and logic are explained a little bit more thoroughly. The book I have only has one paragraph about this stuff. What I am thinking is that I am talking about some concepts or ways of doing PHP programming here, but I just don't know the terms for them yet. I know this isn't a straight forward question, I just need some help in organizing my thoughts.

    Read the article

  • Stable separation for two classes of elements in an array

    - by AndreyT
    Consider the following problem. We are given an array of elements belonging to one two classes: either red or blue. We have to rearrange the elements of the array so that all blue elements come first (and all red elements follow). The rearrangement must be done is stable fashion, meaning that the relative order of blue elements must be preserved (same for red ones). Is there a clever algorithm that would perform the above rearrangement in-place? A non-in place solution is, of course, straightforward. An obvious in-place solution would be to apply any stable sorting algorithm to the array. However, using a full-fledged sorting algorithm on an array intuitively feels like an overkill, especially taking into account the fact that we are only dealing with two classes of elements. Any ideas greatly appreciated.

    Read the article

  • Separation of domain and ui layer in a composite

    - by hansmaad
    Hi all, i'm wondering if there is a pattern how to separate the domain logic of a class from the ui responsibilities of the objects in the domain layer. Example: // Domain classes interface MachinePart { CalculateX(in, out) // Where do we put these: // Draw(Screen) ?? // ShowProperties(View) ?? // ... } class Assembly : MachinePart { CalculateX(in, out) subParts } class Pipe : MachinePart { CalculateX(in, out) length, diamater... } There is an application that calculates the value X for machines assembled from many machine parts. The assembly is loaded from a file representation and is designed as a composite. Each concrete part class stores some data to implement the CalculateX(in,out) method to simulate behaviour of the whole assembly. The application runs well but without GUI. To increase the usability a GUi should be developed on top of the existing implementation (changes to the existing code are allowed). The GUI should show a schematic graphical representation of the assembly and provide part specific dialogs to edit several parameters. To achieve these goals the application needs new functionality for each machine part to draw a schematic representation on the screen, show a property dialog and other things not related to the domain of machine simulation. I can think of some different solutions to implement a Draw(Screen) functionality for each part but i am not happy with each of them. First i could add a Draw(Screen) method to the MachinePart interface but this would mix-up domain code with ui code and i had to add a lot of functionality to each machine part class what makes my domain model hard to read and hard to understand. Another "simple" solution is to make all parts visitable and implement ui code in visitors but Visitor does not belong to my favorite patterns. I could derive UI variants from each machine part class to add the UI implementation there but i had to check if each part class is suited for inheritance and had to be careful on changes to the base classes. My currently favorite design is to create a parallel composite hierarchy where each component stores data to define a machine part, has implementation for UI methods and a factory method which creates instances of the corresponding domain classes, so that i can "convert" a UI assembly to a domain assembly. But there are problems to go back from the created domain hierarchy to the UI hierarchy for showing calculation results in the drawing for example (imagine some parts store some values during the calculation i want to show in the schematic representation after the simluation). Maybe there are some proven patterns for such problems?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >