Search Results

Search found 763 results on 31 pages for 'namespaces'.

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

  • Best practices for using namespaces in C++.

    - by Dima
    I have read Uncle Bob's Clean Code a few months ago, and it has had a profound impact on the way I write code. Even if it seemed like he was repeating things that every programmer should know, putting them all together and putting them into practice does result in much cleaner code. In particular, I found breaking up large functions into many tiny functions, and breaking up large classes into many tiny classes to be incredibly useful. Now for the question. The book's examples are all in Java, while I have been working in C++ for the past several years. How would the ideas in Clean Code extend to the use of namespaces, which do not exist in Java? (Yes, I know about the Java packages, but it is not really the same.) Does it make sense to apply the idea of creating many tiny entities, each with a clearly define responsibility, to namespaces? Should a small group of related classes always be wrapped in a namespace? Is this the way to manage the complexity of having lots of tiny classes, or would the cost of managing lots of namespaces be prohibitive?

    Read the article

  • accessing my public methods from within my namespace

    - by Derek Adair
    I am in the process of making my own namespace in JavaScript... (function(window){ (function(){ var myNamespace = { somePublicMethod: function(){ }, anotherPublicMethod: function(){ } } return (window.myNamespace = window.my = myNamespace) }()); })(window); I'm new to these kinds of advanced JavaScript techniques and i'm trying to figure out the best way to call public methods from within my namespace. It appears that within my public methods this is being set to myNamespace. Should I call public methods like... AnotherPublicMethod: function(){ this.somePublicMethod() } or... AnotherPublicMethod: function(){ my.somePublicMethod(); } is there any difference?

    Read the article

  • Should the include guards be unique even between namespaces?

    - by Arun
    I am using same class name in two namespaces, say A and B. Should the include guards be unique while declaring the classes with different namespaces too? I mean can't there be two files names AFile.h (in different directories) with same include guards and declaring different namespaces? File 1: #ifndef AFILE_H #define AFILE_H namespace A { class CAFile {... }; }; #endif File 2: #ifndef AFILE_H #define AFILE_H namespace B { class CAFile {... }; }; #endif

    Read the article

  • How can I get JDOM/XPath to ignore namespaces?

    - by AdSR
    I need to process an XML DOM, preferably with JDOM, where I can do XPath search on nodes. I know the node names or paths, but I want to ignore namespaces completely because sometimes the document comes with namespaces, sometimes without, and I can't rely on specific values. Is that possible? How?

    Read the article

  • Visual Basic Book Excerpt: Useful Namespaces

    This chapter provides an overview of some of the most important system namespaces and gives more detailed examples that demonstrate regular expressions, XML, cryptography, reflection, threading, parallel programming, and Direct3D....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • PHP PSR-0 + several namespaces in one file and autoload

    - by Nemoden
    I've been thinking for a while about defining several namespaces in one php file and so, having several classes inside this file. Suppose, I want to implement something like Doctrine\ORM\Query\Expr: Expr.php Expr |-- Andx.php |-- Base.php |-- Comparison.php |-- Composite.php |-- From.php |-- Func.php |-- GroupBy.php |-- Join.php |-- Literal.php |-- Math.php |-- OrderBy.php |-- Orx.php `-- Select.php It would be nice if I had all of this in one file - Expr.php: namespace Doctrine\ORM\Query; class Expr { // code } namespace Doctrine\ORM\Query\Expr; class Func { // code } // etc... What I'm thinking of is directories naming convention and, unlike PSR-0 having several classes and namespaces in one file. It's best explained by the code: ls Doctrine/orm/query Expr.php that's it - only Expr.php Since Expr.php is somewhat I call a "meta-namespace" for Expr\Func, it make sense to place all the classes inside Expr.php (as shown above). So, the vendor name is still starts with an uppercased letter (Doctrine) and the other parts of namespace start with lowercased letter. We can write an autoload so it would respect this notion: function load_class($class) { if (class_exists($class)) { return true; } $tokenized_path = explode(array("_", "\\"), DIRECTORY_SEPARATOR, $class); // array('Doctrine', 'orm', 'query', 'Expr', 'Func'); // ^^^^ // first, we are looking for first uppercased namespace part // and if it's not last (not the class name), we use it as a filename // and wiping away the rest to compose a path to a file we need to include if (FALSE !== ($meta_class_index = find_meta_class($tokenized_path))) { $new_tokenized_path = array_slice($tokenized_path, 0, $meta_class_index); $path_to_class = implode(DIRECTORY_SEPARATOR, $new_tokenized_path); } else { // no meta class found $path_to_class = implode(DIRECTORY_SEPARATOR, $tokenized_path); } if (file_exists($path_to_class.'.php')) { require_once $path_to_class.'.php'; } return false; } Another reason to do so is to reduce a number of php files scattered among directories. Usually you check file existence before you require a file to fail gracefully: file_exists($path_to_class.'.php'); If you take a look at actual Doctrine\ORM\Query\Expr code, you'll see they use all of the "inner-classes", so you actually do: file_exists("/path/to/Doctrine/ORM/Query/Expr.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/AndX.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Base.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Comparison.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Composite.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/From.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Func.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/GroupBy.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Join.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Literal.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Math.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/OrderBy.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Orx.php"); file_exists("/path/to/Doctrine/ORM/Query/Expr/Select.php"); in your autoload which causes quite a few I/O reads. Isn't it too much to check on each user's hit? I'm just putting this on a discussion. I want to hear from another PHP programmers what do they think of it. And, of course, if you have a silver bullet addressing this problems I've designated here, please share. I also have been thinking if my vogue question fits here and according to the FAQ it seems like this question addresses "software architecture" problem slash proposal. I'm sorry if my scribble may seem a bit clunky :) Thanks.

    Read the article

  • Way to get VS 2008 to stop forcing indentation on namespaces?

    - by Earlz
    I've never really been a big fan of the way most editors handle namespaces. They always force you to add an extra pointless level of indentation. For instance, I have a lot of code in a page that I would much rather prefer formatted as namespace mycode{ class myclass{ void function(){ foo(); } void foo(){ bar(); } void bar(){ //code.. } } } and not something like namespace mycode{ class myclass{ void function(){ foo(); } void foo(){ bar(); } void bar(){ //code.. } } } Honestly, I don't really even like the class thing being indented most of the time because I usually only have 1 class per file. And it doesn't look as bad here, but when you get a ton of code and lot of scopes, you can easily have indentation that forces you off the screen, and plus here I just used 2-space tabs and not 4-space as is used by us. Anyway, is there some way to get Visual Studio to stop trying to indent namespaces for me like that?

    Read the article

  • C#: Problem trying to resolve a class when two namespaces are simmilar.

    - by rally25rs
    I'm running into an issue where I can't make a reference to a class in a different namespace. I have 2 classes: namespace Foo { public class Class1 { ... } } namespace My.App.Foo { public class Class2 { public void SomeMethod() { var x = new Foo.Class1; // compile error! } } } The compile error is: The type or namespace name 'Class1' does not exist in the namespace 'My.App.Foo' In this situation, I can't seem to get Visual Studio to recognize that "Foo.Class1" refers to the first class. If I mouse-over "Foo", it shows that its trying to resolve that to "My.App.Foo.Class1" If I put the line: using Foo; at the top of the .cs file that contains Class2, then it also resolves that to "My.App.Foo". Is there some trick to referencing the right "Foo" namespace without just renaming the namespaces so they don't conflict? Both of these namespaces are in the same assembly.

    Read the article

  • Why do we need URIs for XML namespaces?

    - by Patryk
    I am trying to figure out why we need URIs for XML namespaces and I cannot find a purpose for that. Can anyone brighten me a little showing their use on a concrete example? EDIT: Ok so for instance: I have this from w3schools <root xmlns:h="http://www.w3.org/TR/html4/" xmlns:f="http://www.w3schools.com/furniture"> <h:table> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> <f:table> <f:name>African Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table> </root> So what should http://www.w3schools.com/furniture hold ?

    Read the article

  • How can I validate XML against an XSD with distinct imports and namespaces?

    - by Pedrolopes
    Hi there!! I am trying to validate a few XML files and I'm failing due to various issues with the XSD definition and the namespaces... This is public info, so no problem sharing data: the main XSD is at http://bioinformatics.ua.pt/euadr/euadr_types.xsd and it imports another XSD at the same location name common_types.xsd, I've validated them in W3C validator, and they passed. The XML <?xml version="1.0"?> <relationship xmlns="http://euadr.biosemantic.erasmusmc.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://euadr.biosemantic.erasmusmc.org/ http://bioinformatics.ua.pt/euadr/euadr_types.xsd"> <sourceId> <source>SMILE</source> <code>[S]1(=O)(=O)N(C(</code> </sourceId> <targetId> <source>UP</source> <code>P35354</code> </targetId> <creator>http://cgl.imim.es</creator> <observationDateTime>2010-05-12T19:03:40.097+02:00</observationDateTime> <informationSources> <informationSource> <relationshipType>BINDS</relationshipType> <interaction> <type>pIC50</type> <value>6.55</value> </interaction> <evidence> <type>OBSERVATIONAL</type> <value>1.0</value> </evidence> <databaseIds> <databaseId> <source>PDSP</source> <code> P35354</code> </databaseId> </databaseIds> </informationSource> </informationSources> </relationship> is straightforward and well-formed! I've tested a few online validators, and I'm getting the following error cvc-elt.1: Cannot find the declaration of element 'relationship'. Does anyone has any idea of what the problem is? Is it in the declaration of the namespaces? Of the XSD? Thanks in advance for your help! Cheers!

    Read the article

  • Is there a Perl module or technique that makes using long namespaces easier?

    - by Robert P
    Some namespaces are long and annoying. Lets say that i downloaded hypothetical package called FooFoo-BarBar-BazBaz.tar.gz, and it has the following modules: FooFoo::BarBar::BazBaz::Bill FooFoo::BarBar::BazBaz::Bob FooFoo::BarBar::BazBaz::Ben FooFoo::BarBar::BazBaz::Bozo FooFoo::BarBar::BazBaz::Brown FooFoo::BarBar::BazBaz::Berkly FooFoo::BarBar::BazBaz::Berkly::First FooFoo::BarBar::BazBaz::Berkly::Second Is there a module or technique I can use that's similar to the C++ 'using' statement, i.e., is there a way I can do using FooFoo::BarBar::BazBaz; which would then let me do my $obj = Brown->new(); ok $obj->isa('FooFoo::BarBar::BazBaz::Brown') ; # true # or... ok $obj->isa('Brown'); # also true

    Read the article

  • .NET and XML: How can I read nested namespaces (<abc:xyz:name attr="value"/>)?

    - by Entrase
    Suppose there is an element in XML data: <abc:xyz:name attr="value"/> I'm trying to read it with XmlReader. The problem is that I get XmlException that says The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name I have already declared "abc" namespace. I have also tried adding "abc:xyz" and "xyz" namespaces. But this doesn't help at all. I could replace some text before parsing but there may be some more elegant solution. So what should I do? Here is my code: XmlReaderSettings settings = new XmlReaderSettings() NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace("abc", ""); nsmgr.AddNamespace("xyz", ""); XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); // So this reader can't read <abc:xyz:name attr="value"/> XmlReader reader = XmlReader.Create(path, settings, context);“

    Read the article

  • Is it possible get the functionality of namespaces inside a class?

    - by CowKingDeluxe
    I have the following code: Public Class Form1 Private Function Step1_Execute() As Boolean Return Step1_Verify() End Function Private Function Step1_Verify() As Boolean Return True End Function Private Function Step2_Execute() As Boolean Return Step2_Verify() End Function Private Function Step2_Verify() As Boolean Return True End Function End Class What I would like to do is be able to separate the code, similar to the following (which obviously doesn't work): Public Class Form1 Namespace Step1 Private Function Step1_Execute() As Boolean Return Step1_Verify() End Function Private Function Step1_Verify() As Boolean Return True End Function End Namespace Namespace Step2 Private Function Step2_Execute() As Boolean Return Step2_Verify() End Function Private Function Step2_Verify() As Boolean Return True End Function End Namespace End Class I would like the functionality of namespaces inside of a class, as in something that would let me call Step2.Execute() instead of having to put Step2_ in front of a whole bunch of functions. I don't want to have to create separate classes / modules for step1, step2, etc. Is there a way that I can accomplish namespace functionality from inside a class?

    Read the article

  • PHP 5.3 Namespaces should i use every PHP function with backslash?

    - by lhwparis
    Hi, im now using namespaces in PHP 5.3 now there is a fallback mechanism for functions which dont exist in the namespace. so php every time checks if the function exists in namespace and then tries to load it from global space. So what about all php internal functions? strstr for example? Should i now use every php internal function with a \ ? to avoid php first checking the namespace? is this fallback a huge performance drop? what do you think?

    Read the article

  • Why are namespaces acting up in Visual Studio 2010?

    - by duluca
    I've just converted a project to VS 2010 and something really weird is going on with namespaces. Let me give an example, the following code used to work in VS2008: MySystem.Core.Object { using MySystem.Core.OtherObject; ... } But now it doesn't, it either wants the whole thing to be put outside of the namespace like this: using MySystem.Core.OtherObject; MySystem.Core.Object { ... } or be rewritten it like: MySystem.Core.Object { using OtherObject; ... } I understand why this works and maybe is the correct way of handling this, but now we'd have to change thousands of lines of code! Which is not cool. Any idea to circumvent this requirement?

    Read the article

  • How to add namespaces to a flex AIR project in Flash Builder 4?

    - by milkplus
    In my ant build.xml script I have... <namespace uri="http://ns.foo.com/mxml/2011" manifest="src/manifest.xml"/> <namespace uri="library://ns.adobe.com/flex/spark" manifest="flex_src/spark-manifest.xml"/> <namespace uri="http://www.adobe.com/2006/mxml" manifest="flex_src/mx-manifest.xml"/> That works! But... I'm not sure how to add these namespaces to my project properties in Flash Builder 4 so I can debug. When I try, it changes this line in my .actionScriptProperties <compiler additionalCompilerArguments="-namespace http://ns.foo.com/mxml/2011 src/manifest.xml -namespace=library://ns.adobe.com/flex/spark flex_src/spark-manifest.xml -namespace http://www.adobe.com/2006/mxml flex_src/mx-manifest.xml" autoRSLOrdering="true" copyDependentFiles="true" fteInMXComponents="false" generateAccessible="true" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin-debug" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="true" useDebugRSLSwfs="true" verifyDigests="true" warn="true"> but gives me a "no default arguments are expected" error. What is the reason for this error? The error location is "Unknown" and seems to refer to these compiler arguments.

    Read the article

  • Getting started with Blocks and namespaces - Enterprise Library 5.0 Tutorial Part 2

    This is my second post in this series. In first blog post I explained how to install Enterprise Library 5.0 and provided links to various resources. Enterprise Library is divided into various blocks. Simply we can say, a block is a ready made solution for a particular common problem across various applications. So instead focusing on implementation of common problem across various applications, we can reuse these fully tested and extendable blocks to increase the productivity and also extendibility as these blocks are made with good design principles and patterns. Major blocks of Enterprise Library 5.0 are as follows.   Core infrastructure Functional Application Blocks Caching Data Exception Handling Logging Security Cryptography Validation Wiring Application Blocks Unity Policy Injection/Interception   Each block resides in its own assembly, and also some extra assemblies for common infrastructure. Assemblies are as follows. Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.dll Microsoft.Practices.EnterpriseLibrary.Caching.Database.dll Microsoft.Practices.EnterpriseLibrary.Caching.dll Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapter.dll Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapterV5.dll Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime.dll Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.dll Microsoft.Practices.EnterpriseLibrary.Data.dll Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll Microsoft.Practices.EnterpriseLibrary.Logging.dll Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll Microsoft.Practices.EnterpriseLibrary.Security.Cache.CachingStore.dll Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll Microsoft.Practices.EnterpriseLibrary.Security.dll Microsoft.Practices.EnterpriseLibrary.Validation.dll Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet.dll Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.dll Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms.dll Microsoft.Practices.ServiceLocation.dll Microsoft.Practices.Unity.Configuration.dll Microsoft.Practices.Unity.dll Microsoft.Practices.Unity.Interception.dll Enterprise Library Configuration Tool In addition to these assemblies you would get configuration tool “EntLibConfig-32.exe”. If you are targeting your application to .NET 4.0 framework then you would need to use “EntLibConfig.NET4.exe”. Optionally you can install Visual Studio 2008 and Visual Studio 2010 add-ins whilst installing of Enterprise Library. So that you can invoke the enterprise Library configuration from Visual Studio by right clicking on “app.config” or “web.config” file as shown below. I would suggest you to download the documentation from Codeplex which was released on May 2010. It consists 3MB of information. you can also find issue tracker to know various issues/bugs currently people talking about enterprise library. There is also discussion link takes you to community site where you can post your questions. In my next blog post, I would cover more on each block. span.fullpost {display:none;}

    Read the article

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