Search Results

Search found 5915 results on 237 pages for 'practices'.

Page 114/237 | < Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >

  • Comparing objects and inheritance

    - by ereOn
    Hi, In my program I have the following class hierarchy: class Base // Base is an abstract class { }; class A : public Base { }; class B : public Base { }; I would like to do the following: foo(const Base& one, const Base& two) { if (one == two) { // Do something } else { // Do something else } } I have issues regarding the operator==() here. Of course comparing an instance A and an instance of B makes no sense but comparing two instances of Base should be possible. (You can't compare a Dog and a Cat however you can compare two Animals) I would like the following results: A == B = false A == A = true or false, depending on the effective value of the two instances B == B = true or false, depending on the effective value of the two instances My question is: is this a good design/idea ? Is this even possible ? What functions should I write/overload ? My apologies if the question is obviously stupid or easy, I have some serious fever right now and my thinking abilities are somewhat limited :/ Thank you.

    Read the article

  • How to format dates in Jahia 6 CMS?

    - by dpb
    I am helping a friend of mine put up a site for his business. I’ve read different posts and sites trying to find the ideal CMS tool, but people have different views of what is the best, so I finally just picked one of them at random. So I went for an evaluation of Jahia 6.0-CE. As you’ve probably guessed by now, I don’t have so much experience with CMS tools. I just want to setup the CMS, write the templates for the site and let my friend manage the content from there on. So I extracted the sources from SVN and went for a test drive. I managed to create some simple templates to get a hang of things but now I have an issue with a date format. In my definitions.cnd I declared the field like so: date myDateField (datetimepicker[format='dd.MM.yyyy']) This is formatted in the page and the selector also presents this in the dd.MM.yyyy format when inserting the content. But how about sites in other countries, countries that represent the date as MM.dd.yyyy for example? If I specify the format in the CND, hard coded, how can I change this later on so that it adapts based on the browser’s language? Do I extract the content from the repository and format it by hand in the JSP template based on a Locale, or is there a better way? Thank you.

    Read the article

  • How do I get mercurial to show the diff during `hg com`?

    - by Kev
    Is there a way to configure hg com so that in the commit message file that pops up in the external editor, instead of just showing which files were changed (in the HG: lines) it actually shows the full diff? I'd rather view the output and compose my commit message simultaneously from the comfort of my text editor as opposed to doing hg diff on the command line separately beforehand.

    Read the article

  • Nested Array with one foreach Loop?

    - by streetparade
    I need to have access to a array which looks like this. Array ( [0] => Array ( [54] => Array ( [test] => 54 [tester] => result ) ) ) foreach($array as $key=>$value) { echo $key;// prints 0 echo $value;// prints Array /* now i can iterate through $value but i dont want it solve that way example: foreach($value as $k=>$v) { echo $k;//prints test echo $v; //prints 54 } */ } How can iterate just once ? to get the values of test and tester? I hope i could explain my problem clear

    Read the article

  • How to pass non-fatal warnings from a library

    - by wRAR
    A library function parses a file and returns an object. If a parser encounters unknown data, missing values etc., it shouldn't throw an exception and stop parsing (because this is not fatal), but there should be a way to pass information about these things to a caller (so that warnings can be displayed in the UI, for example). How can these warning be returned? I'm thinking of passing a callback function/object into the library, are there any other possible solutions?

    Read the article

  • require_once at the beginning or when really needed?

    - by takeshin
    Where should I put require_once statements, and why? Always on the beginning of a file, before the class, In the actual method when the file is really needed It depends ? Most frameworks put includes at the beginning and do not care if the file is really needed. Using autoloader is the other case here.

    Read the article

  • Is there any difference between var name = function() {} & function name() {} in Javascript?

    - by Fletcher Moore
    Suppose we are inside a function and not in the global namespace. function someGlobalFunction() { var utilFunction1 = function() { } function utilFunction2 () { } utilFunction1(); utilFunction2(); } Are these synonymous? And do these functions completely cease to exist when someGlobalFunction returns? Should I prefer one or the other for readability or some other reason?

    Read the article

  • White-box testing in Javascript - how to deal with privacy?

    - by Max Shawabkeh
    I'm writing unit tests for a module in a small Javascript application. In order to keep the interface clean, some of the implementation details are closed over by an anonymous function (the usual JS pattern for privacy). However, while testing I need to access/mock/verify the private parts. Most of the tests I've written previously have been in Python, where there are no real private variables (members, identifiers, whatever you want to call them). One simply suggests privacy via a leading underscore for the users, and freely ignores it while testing the code. In statically typed OO languages I suppose one could make private members accessible to tests by converting them to be protected and subclassing the object to be tested. In Javascript, the latter doesn't apply, while the former seems like bad practice. I could always wall back to black box testing and simply check the final results. It's the simplest and cleanest approach, but unfortunately not really detailed enough for my needs. So, is there a standard way of keeping variables private while still retaining some backdoors for testing in Javascript?

    Read the article

  • Is this SQL select code following good practice?

    - by acidzombie24
    I am using sqlite and will port to mysql (5) later. I wanted to know if I am doing something I shouldnt be doing. I tried purposely to design so I'll compare to 0 instead of 1 (I changed hasApproved to NotApproved to do this, not a big deal and I haven't written any code). I was told I never need to write a subquery but I do here. My Votes table is just id, ip, postid (I don't think I can write that subquery as a join instead?) and that's pretty much all that is on my mind. Naming conventions I don't really care about since the tables are created via reflection and is all over the place. select id, name, body, upvotes, downvotes, (select 1 from UpVotes where IPAddr=? AND post=Post.id) as myup, (select 1 from DownVotes where IPAddr=@0 AND post=Post.id) as mydown from Post where flag = '0' limit ?, ?"

    Read the article

  • Concatenating Strings in Obj C

    - by eco_bach
    Hi It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely difficult. I simply need to create a sequence of strings, image1.jpg, image2.jpg, etc etc ie in a loop var imgString:String='image'+i+'.jpg; I assume a best practice is to use a NSMutableString with appendString method? What am I doing wrong?? NSMutableString *imgString; for(int i=1;i<=NUMIMAGES;i++){ imgString.appendString(@"image"+i+@".jpg"); } I get the following error error: request for member 'appendString' in something not a structure or union

    Read the article

  • How to reference a class that implements certain interface?

    - by vikp
    Hi, I have an interface for logging the exceptions, i.e. IExceptionLogger. This interface has 3 implementations: DBExceptionLogger, XMLExceptionLogger, CSVExceptionLogger. I have an application that will make a use of DBExceptionLogger. The application references only IExceptionLogger. How do I create an instance of DBExceptionLogger within the application. I can't reference the DBExceptionLogger directly since it will break the purpose of having IExceptionLogger interface. Thanks

    Read the article

  • What is the reason not to use select * ?

    - by Chris Lively
    I've seen a number of people claim that you should specifically name each column you want in your select query. Assuming I'm going to use all of the columns anyway, why would I not use SELECT *? Even considering the question from 9/24, I don't think this is an exact duplicate as I'm approaching the issue from a slightly different perspective. One of our principles is to not optimize before it's time. With that in mind, it seems like using SELECT * should be the preferred method until it is proven to be a resource issue or the schema is pretty much set in stone. Which, as we know, won't occur until development is completely done. That said, is there an overriding issue to not use SELECT *?

    Read the article

  • Symfony 1.3: Any opinion about this code? Coud be shorter or better?

    - by user248959
    Hi, I need your opinion about this code below. I have a list of messages: each message has a link that change the state of the message (read - non read). In the partial "_message" i have this: <div class="switching_link" id="switching_link_<?php echo $message ?>"> echo include_partial('link_switch_state', array('message' => $message)) </div> In the partial "_link_switch_state" i have this: if((int)$message->getState() == 1) { $string_state_message="non read"; } else { $string_state_message="read"; } echo link_to_remote('Mark as '.$string_state_message, array( 'url' => 'message/switchState?id='.$message->getId(), 'update' => 'switching_link_'.$message, "complete" => "switchClassMessage('$message');", )); And in message/actions/actions.class.php i have this: public function executeSwitchState(sfWebRequest $request) { // searching the message we want to change its state. $this->messages = Doctrine::getTable('Message')->findById($request->getParameter('id')); // changing the state of the message. if($this->messages[0]->getState() == 1) { $this->messages[0]->setState(0); } else { $this->messages[0]->setState(1); } $this->messages[0]->save(); // rendering the partial that shows the link ("Mark as read/non read"). return $this->renderPartial('mensaje/link_switch_state', array( 'message' => $this->messages[0])); } Regards Javi

    Read the article

  • Does MVC replace traditional manually created BLL?

    - by used2could
    I'm used to creating the UI, BLL, DAL by hand (some times I've used LINQ-to-SQL or SubSonic for the DAL). I've done several small projects using MVC since its release. On these projects I've still continued to write a BLL and DAL by hand and then incorporate those into the MVC's models/controllers. I'm looking to optimize my time on projects this seems like overkill and a potential waste of time. Question Would it be acceptable to roll a DAL such as SubSonic and directly use it in the Models/Controllers of my MVC web app? Now the models & controllers would act as the BLL. I just see this as a major timesaver to not have to worry about another tier. UPDATE: I just wanted to add that my concern isn't really with the DAL (I frequently use SubSonic and NH) but rather focus on the BLL. Sorry for the confusion.

    Read the article

  • User submitted content filtering

    - by Jim
    Hey all, Does anyone have any ideas on what could be used as a way to filter untrustworthy user submitted content? Take Yelp for instance, they would need to prevent competitors writing business reviews on their competitors. They would need to prevent business owners favourably reviewing their own business, or forcing friends/family to do so. They would need to prevent poor quality reviews from affecting a businesses rating and so on. I can't think what they might use to do this: Prevent multiple users from the same IP reviewing certain things Prevent business owners reviewing their own business (maybe even other businesses in the same categories as their own?) Somehow determine what a review is about and what the actual intentions behind it are Other than the first and second points, I can't think of any clever/easy way to filter potentially harmful reviews from being made available, other than a human doing it. Obviously for a site the size of Yelp this wouldn't be feasible, so what parameters could they take into consideration? Even with human intervention, how would anyone know it was the owners best buddy writing a fake review without knowing the people? I'm using this as an example in a larger study on the subject of filtering user content automatically. Does anyone have any ideas how these systems may work and what they take into consideration? Thanks!

    Read the article

  • Zend_Form: Is this really the way we should be doing things?

    - by Francis Daigle
    OK. I understand how to use Zend_Form and it's implementation of the decorator pattern. My question is, is this the best way to be going about creating forms? Shouldn't a documents forms be left to to the front-end rather than generating forms programmatically? Doesn't this kinda violate the whole idea of keeping things separate? I mean, really, even providing that you have a good understanding of the methodology being employed, does it really save one that much time? I guess what I'm looking for is some guidance as to what might be considered 'best practice'. I'm not saying that Zend_Form doesn't have it's place, I'm just wondering if it should be used in all cases (or not). And this has nothing to do with validation. I'm just thinking that something more akin to using the 'ViewScript' approach might be more appropriate in most cases. Your thoughts?

    Read the article

  • Formating a date field in the Model (Codeigniter)

    - by Landitus
    Hi, I', trying to re-format a date from a table in Codeigniter. The Controller is for a blog. I was succesfull when the date conversion happens in the View. I was hoping to convert the date in the Model to have things in order. This is the Model: class Novedades_model extends Model { function getAll() { $this->db->order_by('date','desc'); $query = $this->db->get('novedades'); if($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } } return $data; } } This is part of the controller $this->load->model('novedades_model'); $data['records'] = $this->novedades_model->getAll(); Here's the date conversion as it happens in the View. This is inside the posts loop: <?php foreach($records as $row) : ?> <?php $fdate = "%d <abbr>%M</abbr> %Y"; $dateConv = mdate($fdate, mysql_to_unix($row->date)); ?> <div class="article section"> <span class="date"><?php echo $dateConv ;?></span> ... Keeps going ... How can I convert the date in the Model? Can I access the date key and refactor it?

    Read the article

  • Request/Response pattern in SOA implementation

    - by UserControl
    In some enterprise-like project (.NET, WCF) i saw that all service contracts accept a single Request parameter and always return Response: [DataContract] public class CustomerRequest : RequestBase { [DataMember] public long Id { get; set; } } [DataContract] public class CustomerResponse : ResponseBase { [DataMember] public CustomerInfo Customer { get; set; } } where RequestBase/ResponseBase contain common stuff like ErrorCode, Context, etc. Bodies of both service methods and proxies are wrapped in try/catch, so the only way to check for errors is looking at ResponseBase.ErrorCode (which is enumeration). I want to know how this technique is called and why it's better compared to passing what's needed as method parameters and using standard WCF context passing/faults mechanisms?

    Read the article

  • Can I use an abstract class instead of a private __construct() when creating a singleton in PHP?

    - by Pheter
    When creating a Singleton in PHP, I ensure that it cannot be instantiated by doing the following: class Singleton { private function __construct() {} private function __clone() {} public static function getInstance() {} } However, I realised that defining a class as 'abstract' means that it cannot be instantiated. So is there anything wrong with doing the following instead: abstract class Singleton { public static function getInstance() {} } The second scenario allows me to write fewer lines of code which would be nice. (Not that it actually makes much of a difference.)

    Read the article

  • Why do I need to give my options a value attribute in my dropdown? JQuery related.

    - by Alex
    So far in my web developing experiences, I've noticed that almost all web developers/designers choose to give their options in a select a value like so: <select name="foo"> <option value="bar">BarCheese</option> // etc. // etc. </select> Is this because it is best practice to do so? I ask this because I have done a lot of work with jQuery and dropdown's lately, and sometimes I get really annoyed when I have to check something like: $('select[name=foo]').val() == "bar"); To me, many times that seems less clear than just being able to check the val() against BarCheese. So why is it that most web developers/designers specify a value paramater instead of just letting the options actual value be its value? And yes, if the option has a value attribute I know I can do something like this: $('select[name=foo] option:contains("BarCheese")').attr('selected', 'selected'); But I would still really like to know why this is done. Thanks!!

    Read the article

  • Should I *always* import my file references into the database in drupal?

    - by sprugman
    I have a cck type with an image field, and a unique_id text field. The file name of the image is based on the unique_id. All of the content, including the image itself is being generated automatically via another process, and I'm parsing what that generates into nodes. Rather than creating separate fields for the id and the image, and doing an official import of the image into the files table, I'm tempted to only create the id field and create the file reference in the theme layer. I can think of pros and cons: 1) Theme Layer Approach Pros: makes the import process much less complex don't have to worry about syncing the db with the file system as things change more flexible -- I can move my images around more easily if I want Cons: maybe not as much The Drupal Way™ not as pure -- I'll wind up with more logic on the theme side. 2) Import Approach Pros: import method is required if we ever wanted to make the files private (we won't.) safer? Maybe I'll know if there's a problem with the image at import time, rather than view time. Since I'll be bulk importing, that might make a difference. if I delete a node through the admin interface, drupal might be able to delete the file for me, as well. Con: more complex import and maintenance All else being equal, simpler is always better, so I'm leaning toward #1. Are there any other issues I'm missing? (Since this is an open ended question, I guess I'll make it a community wiki, whatever that means.)

    Read the article

< Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >