During the last years I always thought that in Java, Reflection is widely used during Unit testing. Since some of the variables/methods which have to be checked are private, it is somehow necessary to read the values of them. I always thought that the Reflection API is also used for this purpose.  Last week i had to test some packages and therefore write some JUnit tests. As always i used Reflection to access private fields and methods. But my supervisor who checked the code wasn't really happy with that and told me that the Reflection API wasn't meant to use for such "hacking". Instead he suggested to modifiy the visibility in the production code.  Is it really bad practice to use Reflection? I can't really believe that-  Edit: I should have mentioned that i was required that all tests are in a separate package called test (so using protected visibilty e.g. wasn't a possible solution too)
How do I unit test (using xUnit) a class that has internal private methods, fields or nested classes? Or a function that is made private by having  (static in C/C++) or is in a private () namespace?  It seems bad to change the access modifier for a method or function just to be able to run a test.
Given that   $x^x = y$; and  given some value for $y$   is there a way to expressly solve that equation for $x$? How to specify ec2 instance types for different services? After I have specified a default EC2 instance type for my Juju charm, how do I override that for one of the services?  For instance, the  deploys wordpress and mysql, and I can set the default-instance-type in my environments.yaml so both services are m1.small  But how do I configure it so that (only) the mysql service gets deployed on an instance type better suited to a database, like m2.xlarge ? How do I evaluate $\int \frac{\mathrm{d}x}{e^x + 1} $? How do I solve evaluate $$\int \frac{\mathrm{d}x}{e^x + 1}\ ?$$  I know that I have to use $u$ substitution but I can't seem to find something to substitute with. What are the complexity guarantees of the standard containers? Is it possible to use "negative sound waves" to "cancel out" a sound to create silence? In C# why can't a conditional operator implicitly cast to a nullable type How can I install Visual Studio? How can I install Visual Studio?    I'd prefer to use it in Wine or PlayOnLinux if possible. What is the role of NS records at the apex of a DNS domain? $ORIGIN example.com. ; not necessary, using this to self-document  $TTL 3600 @        IN     SOA   ns1.example.com. admin.example.com. (                       1970010100 7200 1800 1209600 300)  @        IN     NS   ns1.example.com. @        IN     NS   ns2.example.com.  @        IN     A    198.51.100.1 ns1      IN     A    198.51.100.2 ns2      IN     A    198.51.100.3  sub1     IN     NS   ns1.example.edu.  sub2     IN     NS   ns1.sub2 ns1.sub2 IN     A    203.0.113.1 ; inline glue record   The role of a NS record beneath the apex of a domain is well-understood; they exist to delegate authority for a subdomain to another nameserver. Examples of this above would include the NS records for sub1 and sub2. These allow the nameserver to hand out referrals for portions of the domain that it does not consider itself authoritative for.  The purpose of the NS records at the apex of a domain, ns1 and ns2 in this case, seem to be less understood by the internet at large. My understanding (which may not be holistic) is as follows:   They are not used by caching DNS servers in order to determine the authoritative servers for the domain. This is handled by , which is defined at the registrar level. The registrar never uses this information to generate the glue records. They  used to delegate authority for the entire domain to other nameservers. Trying to do so with software such as ISC BIND will not result in the "expected" referral behavior at all, as the nameserver will continue to consider itself authoritative for the zone. They are not used by the nameserver to determine whether it should return authoritative responses (AA flag set) or not; that behavior is defined by whether the software is told to be a master or a slave for the zone. Most nameserver software will quite happily serve apex NS records that disagree with the information contained by the upstream glue records, which will in turn cause well-known DNS validation websites to generate warnings for the domain.   With this being the case, what are we left with? Why are we defining this information if it doesn't appear to be consumed by caching DNS servers on the internet at large? Is it possible to do a cross page POST to an ASP.NET, from a static HTML form? How should I add users non-interactively? I have a set of users I need to add to a new system as part of a BASH script that preps my server. How can I non-interactively add the user, create their home directory, set the group, and enter a default password?  For example, if I needed to add the following users, how would I go about that?  user: node password: spoon group: ultraMegaPermissions  user:serve password: spoot group: sortaNotMega  user:watcher password: spoogle group: notMega How does conservation work in wormholes? My questions might seem naive as I haven't plunged into the mathematical descriptions, but wormholes are interesting even if I don't actually know them :)  First of all, is wormhole making two possible paths betwwen points (like the tunnel in most visualisations) or is it just making two points beside each other like in the game Portal? Of course, second case can be bent into a tunnel, but there would be nothing special about tunnel part and no preferred way to divide into "normal" and "tunnel" part of spacetime.  My main questions are these:   Is momentum conserved? Is kinetic energy conserved? How does potential energy work?   To elaborate... In the game Portal you can fall into floor and fly out of the wall or floor elsewhere with the same speed, but another direction (normal to the portal). So momentum is not conserved, but kinetic energy is. Is that how it would actually work? Where does the momentum go then?  And does it really allow you to increase your potential energy while retaining kinetic? It would seem fair to take away some kinetic energy if you are put in a region where you have more potential energy.  Either way is the change in energy non-continuous like in the game and discussion that's linked below? Or are there just more than one way to move through but the change in potential energy is smooth in any of those? That would mean more potential equilibrium points though...  Similar questions has been discussed , is it correct about how the falling guys gets a lot of energy (in form of a potential one) by draining it from the mouths? How many square meters "twenty feet square" is? One would assume it to be about 2 square meters, but this is obviously not the case. In fact, I'm reading Illium by Dan Simmons. A quote follows:     Much like the room they had faxed into, this space was windowless and about twenty feet square. But unlike the other room, this one was warm, lighted, and free of snow or ice. And unlike the other room, this one was almost filled with an oval metal machine about fifteen feet long.   By this description, "twenty feet square" seems to mean 20x20 feet aka 400 square feet or 40 square meters. Given that Dan Simmons is a renowned American writer, it's not likely that he just can't speak English correctly. So, who's right and who's wrong here? Counter ions and charge of a complex how can I add the charge and the counter ions to my complex? I'm using chemfig.  \schemestart \chemname{\chemleft[\chemfig{Ni (&lt;:[1]OH_2) (-[2]OH_2) (&lt;:[3]OH_2) (&lt;[5]OH_2) (-[6]OH_2) (&lt;[7]OH_2) }\chemright]}{\ce{[Ni(OH2)6]Cl2}} \schemestop     Thanks! ok, ive a class and i pass an object as property.  the object that i pass is a List&lt;X&gt;  in my class im trying to access the Object index by reflection BUT I CAN'T!!!   Example:  this class works i just wrote down the part i want to show you and i need help.  class MyClass {     private object _recordSet;     public object RecordSet     {         get { return _recordSet; }         set { _recordSet = value; }     }      public string Draw()     {         system.reflection.Assembly asem = system.reflection.Assembly.getAssembly(_dataSource.GetType());          object instance;          instance = asem.CreateInstance(_dataSource.GetType().UnderlyingSystemType.FullName);          //to access de Count of my List         int recordcount = int.Parse(_dataSource.GetType().GetProperty("Count").GetValue(_dataSource,null));          //i need to do a          for(int cont = 0; cont &lt; recordCount; cont++)         {             _dataSource[cont].Name; // &lt;-- THIS PART IS NOT WORKING!!! because i cant access the Index Directly.... WHAT TO DO!! ???         }     } } How to extract BibTeX entries (as DOI, abstract, etc.) I want to automate personal reading notes generation, I'd like to be able to automatically extract a field's content from a BibTeX entry (other than year or author).  E.g. given a BibTeX entry  @article{einstein05,    author={Albert Einstein},    title={Zur Elektrodynamik bewegter K{\"o}rper},    abstract={Interesting article, which claims that time is relative.},    journal={Annalen der Physik und Chemie},    volume={17},    year={1905},    pages={891--921} }   I want to have a macro in my TeX file (e.g. \citeabstract) that will return the string Interesting article, which claims that time is relative. (the same for DOI, etc.)  I've found the \printfield command that might help me, but I'm not smart enough to know how to use it.  I don't know if it has any influence on the answer, but I'm using BibLaTeX+BibTeX. No connection could be made because the target machine actively refused it (PHP / WAMP) How to show textures in the 3D View editor? I have added some textures to objects in blender but the textures don't show up until I render the file. it can be difficult to know what the objects look like without rendering it. is there a way to have textures show in the editor even if they are at a lower res?  In editor:    Rendered: $a,b,m,n$ be positive integers such that g.c.d.$(a,b)=1$ and $a^m+b^m|a^n+b^n$ , then $m|n$? Let $a,b,m,n$ be positive integers such that g.c.d.$(a,b)=1$ and $a^m+b^m|a^n+b^n$ , then is it true that $m$ divides $n$ ? How to adjust font features in LuaTeX? As of version 2.7 of luaotfload the support for font feature files (.fea) .  On the  Hans showed how to make font substitution work through Lua.  More examples are available in the latest ConTeXt distribution (, , , , , , )  In the past I have been using font feature files to adjust the kerning of fonts on-the-fly.  From Hans' example it is not clear to me how to adjust kerning in the new syntax.  The below example does not work as intended.  \documentclass{article} \usepackage{fontspec} \directlua{ fonts.handlers.otf.addfeature {     name = "kern",     {         type = "pair",         data = {             [0x0041] = { [0x0056] = { false, { -200, 0, 0, 0 } } },         }     } } } \setmainfont{Latin Modern Roman} \begin{document} AV \end{document}   Can we have a comprehensive guide on how to adjust font features with LuaTeX with the fonts.handlers technique?    Related questions:  (These involve hooking into the luaotfload.patch_font callback) Is the intersection of a closed set and a compact set always compact?