coding-style

Why does .NET's StringValidator's Validate method throws an exception when it doesn't succeed?

℡╲_俬逩灬. 提交于 2019-12-06 12:14:15
As you can see in the MSDN StringValidator documentation , the Validate method returns void . If validation doesn't succeed the Validate method throws ArgumentException . I thought that "You only throw an exception when something exceptional happens". Surely a validator that failed to validate isn't exceptional.. Why not return bool? What am I missing here? Is this a "style issue" (i.e. if it was returning bool, it would still be correct, but just different style)? Note: Method CanValidate may have something to do with it, but I still see no reason for this behavior. see ArgumentException

Style facebook 'like' button

家住魔仙堡 提交于 2019-12-06 11:33:39
问题 I'm struggling with this for a while now and without any success. Setting the style with jquery doesn't work, the same with after the facebook iframe. Is there a way to perform this task ? <iframe src="http://www.facebook.com/plugins/like.php?&href=http%3A%2F%2Fwww.example.com&layout=standard&show_faces=false&width=400&action=like&font=tahoma&colorscheme=light&height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:400px; height:23px;" allowTransparency="false"><

Whats the appropriate form when dispatching events in AS3?

佐手、 提交于 2019-12-06 11:28:17
I was wondering what the appropriate form was when creating custom events? Should one create a CustomEvent class, and then create a temporary dispatcher in the function, and dispatch the CustomEvent. or is it better to attempt to create a CustomEventDispatcher class, and create the CustomEvent class as an internal class of that class, eg: package { public class CustomEventDispatcher extends EventDispatcher { public function CustomEventDispatcher() { super(new CustomEvent()); } } } class CustomEvent { public function CustomEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) {

Is using static private methods really faster/better than instance private methods?

核能气质少年 提交于 2019-12-06 10:27:47
问题 What I'm asking is whether there is a difference between doing this: public Something importantBlMethod(SomethingElse arg) { if (convenienceCheckMethod(arg)) { // do important BL stuff } } private boolean convenienceCheckMethod(SomethingElse arg) { // validate something } And this: public Something importantBlMethod(SomethingElse arg) { if (convenienceCheckMethod(arg)) { // do important BL stuff } } private static boolean convenienceCheckMethod(SomethingElse arg) { // validate something } I

Silverlight Listbox Item Style

蹲街弑〆低调 提交于 2019-12-06 09:42:27
How would one go about styling a listbox such that the selection has a different text color than the default view? I've looked at this in several ways and because the ContentPresenter lacks a Foreground property. The default control template of the listbox provides several rectangles which one can use to adjust the highlight color. For example, with the default style a rectangle called BGColor3 has its opacity adjusted to get a highlight effect. Here is the bulk of my control template: <Grid> <Rectangle x:Name="BGColor2" Fill="{StaticResource HoverBrush}" Stroke="Black" StrokeThickness="1"

How to write gnatcheck rules

本小妞迷上赌 提交于 2019-12-06 09:35:04
Is it possible to write your own gnatcheck rules, and if so, can someone point me to a good reference? I am searching for a particular "style" that is being used, and would love if I could simply write a rule that says if you see said style, it will throw up a warning, or an error, this way we can flag when this isn't following a particular standard. A bit of background may be helpful here. While the style checks hold out a lot of promise for enforcing user style guidelines, that isn't exactly what they are for. The main purpose of those checks is to enforce Ada Core 's (The folks who maintain

Java eclipse highlight missing brackets

强颜欢笑 提交于 2019-12-06 09:26:48
I just can't find the option anywhere. Is there some way in eclipse to warn about stuff like this? if(a==b)continue; instead of if(a==b){continue;} Or can maybe the format function fix this? CheckStyle is a nice tool which can also be used as a plugin for eclipse. You can specify different kinds of coding styles you want to enforce on you / your team, by configuring rules in this tool. This could help you create your custom check. Window-->Preferences--> Java > Editor > Save Actions-->Additional actions-->Configure-->Code Style--> Use blocks in if/while... here you can configure the style you

php OOP Exceptions or die()?

↘锁芯ラ 提交于 2019-12-06 08:47:31
I am developing some project. And I want to control different errors. I know that in all popular frameworks and php projects there are different Exceptions. But I think that is not required work. If the error is occured we can make die() with our message. 1. What are the main pluses of Exceptions? 2. Can I control my errors with die()? Thank you. Well, you could use die() . But that makes all errors fatal. Meaning that you cannot try to recover from the error at all. In some cases that's fine to do. But in most cases, you may want the ability to "clean up" after the error, or to try another

Java naming convention with acronyms [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-06 05:51:27
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Java Naming Convention with Acronyms Is it getXml() or getXML()? Is there any official Sun/Oracle document on this? 回答1: Both are correct. Use your preferred way, and be consistent with it throughout your code. 回答2: You'll find both in the Java Standard API, so if there is a convention, it's not being widely followed. 回答3: Not specified Except for variables, all instance, class, and class constants are in mixed

Why is it “easier to ask forgiveness than it is to get permission” in Python?

两盒软妹~` 提交于 2019-12-06 05:43:35
问题 Why is "Easier to Ask Forgiveness than it is to get Permission" (EAFP) considered good practice in Python? As a programming novice I have the impression that using many try...except routines will rather lead to bloated and less readable code than compared to using other checks. What is the advantage of the EAFP approach? NB: I know there are similar questions here, but they mostly refer to some specific example, while I am more interested in the philosophy behind the principle. 回答1: LBYL, the