This is an old revision of the document!
Table of Contents
Study Questions - Lucy Dip Creation
1. Copy the source of the questions and paste into Notepad++.
2. Remove the tag bit at the bottom.
3. In regular expression mode, replace
^====+.+====$
with nothing.
4. In extended mode, replace
/* --== Answer Question separator ==-- */
with
<html>\n </td>\n </tr>\n <tr>\n <td width="50%">\n</html>\n
5. In extended mode, replace
/* --== Question Answer separator ==-- */
with
\n<html>\n </td>\n <td width="50%">\n</html>
6. Replace the first html element with
<html> <table border="1" width="100%"> <tr> <td width="50%"> </html>
7. Add this to end
<html> </td> </tr> </html>
8. Select all and copy to the clipboard.
9. Goto http://tallguyracing.com/wiki/doku.php?id=playground:playground and edit.
10. Paste from the clipboard and save it.
11. Select it (including the RSS XML Feed etc buttons).
12. Open a new document in OpenOffice and paste the contents into it.
13. Set the Zoom to 73% (so that there are two pages per screen).
14. Delete all the crap at the top.
15. Load styles → Wiki Export 2, Text + Pages + Overwrite.
16. Right click table → Table… → Text Flow tab → Untick Allow row to break…
17. For each page,
17.1. Put the cursor in the last row of the page.
17.2. Click the Insert Row button lots.
17.3. Copy and paste the all the cells on the first page to the second. Note that this will overwrite the cells, so if there are not some blanks leftover, undo and go back to 17.2.
17.4. Delete the blank cells.
18. Modify the paragraph style 'Table Contents'. Change the Font colour to black.
19. Highlight the right columns of odd pages and the left columns of the even pages (inside ones if two pages are displayed at once), change the background colour to black. Also, look for numbered bullet lists in the right column of the even pages and reset the numbering.
20. Select everything and paste into the master StudyQuestions file.
Questions To Be Lucky Dipped
Lesson 2: Debugging and Tracing
C10L2Q1: How can you programmatically signal a break to the debugger?
Answer: Call the Debugger.Log method.
C10L2Q2: How do you prevent a member from appearing in the variable watch window while debugging?
Answer: Add a DebuggerBrowsable attribute to the member and pass in DebuggerBrowserState.Never.
C10L2Q3: How do you specify what text will appear in the Value column of the variable watch window for a custom class while debugging?
Answer: Add a DebuggerDisplay attribute to the member.
C10L2Q4: What does the DebuggerDisplay attribute do?
Answer: Specifies what should be displayed in the Value column of the variable watch window while debugging.
C10L2Q5: What does the DebuggerHidden attribute do?
Answer: It prevents the debugger from breaking inside a class, method or property, even if there is a breakpoint.
C10L2Q6: How do you prevent the debugger from breaking inside a class, method or property, even if there is a breakpoint?
Answer: Add a DebuggerHidden attribute to the class, method or property.
C10L2Q7: How do you cause the debugger to automatically step over a section of code?
Answer: Add a DebuggerStepThrough attribute to the code.
C10L2Q8: What does the DebuggerStepThrough attribute do and how is it different to the DebuggerHidden attribute?
Answer: The DebuggerStepThrough attribute causes the debugger to step over the code it decorates, but does not hide the code like the DebuggerHidden attribute does.
Lesson 3: Monitoring Performance
C10L3Q1: What is the difference between the Trace class and the Debug class?
Answer: The Trace class is implemented in both the release and debug builds, whereas Debug is only implemented in debug builds.
C10L3Q2: What are the four primary methods of getting a reference to a process or processes?
Answer: The GetCurrentProcess, GetProcessById, GetProcessByName and GetProcesses.
C10L3Q3: How do you start an external executable from .NET code?
Answer: Call the Process.Start method.
C10L3Q4: How do you start an external executable with command line arguments from .NET code?
Answer: Create or get a reference to a ProcessStartInfo object, set the Arguments property and pass it to the Process.Start method.
C10L3Q5: What object type should secure text be stored in?
Answer: SecureString
Lesson 4: Detecting Management Events
C10L4Q1: What are the four most important members of the System.Management namespace?
Answer: ManagementQuery, EventQuery, ObjectQuery and ManagementObjectQuery.
C10L4Q2: What does WMI stand for?
Answer: Windows Management Instrumentation.
C10L4Q3: What are the two steps to retrieve information from the WMI?
Answer:
- Create a ManagementObjectSearcher object and pass the query into the constructor.
- Obtain a ManagementObjectCollection object by calling the ManagementObjectSearcher's Get method.
C10L4Q4: What needs to be selected from to enumerate the logical drives?
Answer: Win32_LogicalDisk
C10L4Q5: What needs to be selected from to enumerate the network adapters?
Answer: Win32_NetworkAdapterConfiguration
C10L4Q6: What needs to be selected from to enumerate the Windows Services?
Answer: Win32_Service
C10L4Q7: What class would be used to respond a change in the WMI?
Answer: ManagementEventWatcher
Lesson 1: Understanding Code Access Security
C11L1Q1: What does CAS stand for?
Answer: Code Access Security.
C11L1Q2: What is the relationship between evidence, code groups and permission sets?
Answer: The evidence that an assembly has determines what code group or groups it belongs to. The code group or groups determines what permission set or sets it gets.
C11L1Q3: What are the two types of evidence?
Answer: Host evidence and assembly evidence.
C11L1Q4: What are the three CAS policy levels and which one would you most commonly use?
Answer: Enterprise, machine and user. Machine policy is the most commonly used.
C11L1Q5: What must an assembly have to increase its trust?
Answer: A strong name.
C11L1Q6: As a developer, the permission set assigned to the My_Computer_Zone should be changed from what to what?
Follow up question: Why should it be changed?
Answer: From “Full Trust” to “Everything”.
Follow up answer: Full Trust completely skips all CAS statements in code. The Everything permission set has similar permissions, but it does not skip CAS statements.
C11L1Q7: What is the command line utility for maintaining CAS settings?
Answer: Caspol.exe - Code Access Security POLicy tool.
Lesson 2: Using Declarative Security to Protect Assemblies
C11L2Q5: What are the three SecurityActions?
Answer: RequestMinimum, RequestOptional and RequestRefuse.
C11L2Q6: CAS declarations are in what type of assemblies?
Answer: Fully trusted assemblies (or assemblies with the Full Trust permission set).
Lesson 3: Using Declarative and Imperative Security to Protect Methods
C11L3Q1: How many declarative CAS security actions are available for assemblies and how many are available for methods?
Answer: Three for assemblies, six for methods.
C11L3Q2: What are the three declarative CAS security actions for assemblies?
Answer: RequestMinimum, RequestOptional and RequestRefuse.
C11L3Q3: What are the six declarative CAS security actions for methods?
Answer: Assert, Demand, Deny, InheritanceDemand, LinkDemand, and PermitOnly.
C11L3Q4: What is the difference between the Demand CAS security action and the LinkDemand CAS security action?
Answer: Demand checks the security of all the callers, LinkDemand only checks the security of the immediate caller.
C11L3Q5: Which class is used to specify what to check for in a declarative permission statement and which is used in an imperative permission statement?
Answer: Declarative permission statements use SecurityAction, imperative permission statements use CodeAccessPermission.
C11L3Q6: How should a method check if it has a particular CAS permission?
Answer: Call the System.Security.SecurityManager.IsGranted method.
C11L3Q7: Which two security actions reduce CAS permissions for a method and what is the difference between the two?
Answer: Deny and PermitOnly. Deny removes only the specified permission, PermitOnly removes all except the specified permission.
C11L3Q8: Which two security actions reduce CAS permissions for an assembly and what is the difference between the two?
Answer: RequestRefuse and RequestOptional. RequestRefuse removes only the specified permission, RequestOptional removes all except the specified permission.
C11L3Q9: Deny and PermitOnly perform similar functions to what?
Answer: RequestMinimum and RequestOptional.
C11L3Q10: RequestMinimum and RequestOptional perform similar functions to what?
Answer: Deny and PermitOnly.
C11L3Q11: As the security action Assert can only be used once in a method, how can multiple CAS permissions be asserted?
Answer: Add the permissions to a PermissionSet object and assert that.
Lesson 2: Exposing .NET Components to COM
C13L2Q1: When .NET components are consumed by COM, what handles the marshalling between .NET and COM?
Answer: The COM Callable Wrapper (CCW).
C13L2Q2: How do you hide a public .NET class from COM?
Answer: Give it a ComVisible attribute and pass in false.
C13L2Q3: What is used to export an assembly to COM?
Answer: Visual Studio or the Type Library Exporter Utility.
Lesson 3: Using Unmanaged Code
C13L3Q4: What attribute is used to specify a library when creating a P/Invoke?
Answer: DllImport
C13L3Q5: What attribute is used to determine what order members of a structure are stored in memory?
Answer: StructLayoutAttribute
C13L3Q6: What are the three methods for determining what order members of a structure are stored in memory and how are they specified?
Answer: Auto, sequential and explicit. An instance of LayoutKind is passed to the attribute StructLayout.
Lesson 1: Understanding Reflection
C14L1Q1: What are the four parts of an assembly?
Answer: Assembly metadata (or manifest), type metadata, code and resources.
C14L1Q2: What is the relationship between assemblies, modules and types?
Answer: An assembly can contain one or more modules (although typically just one). A module can contain one or more types. An assembly can not directly contain a type (or types must be contained in a module).
Lesson 2: Assembly Attributes
C14L2Q1: How do you get a reference to the current assembly?
Answer: Call the Assembly.GetExecutingAssembly method.
C14L2Q2: Using reflection, how can you get a collection of all the attributes that a class has?
Answer: Call the Assembly.GetCustomAttributes method, which will return an array.
C14L2Q3: What happens when the revision part of the version number in the AssemblyVersionAttribute is set to an asterisk?
Answer: It will be replaced with a random number by the compiler.
C14L2Q4: What happens when the build part of the version number in the AssemblyVersionAttribute is set to an asterisk?
Answer: It will be replaced with an automatically incrementing number by the compiler.
Lesson 3: Reflecting Types
C14L3Q1: How do you create a Type object based on a particular object?
Follow up question: How do you create a Type object based on a particular class?
Answer: Call the object's GetType method.
Follow up answer: Use the typeof keyword.
C14L3Q2: If a string has been cast into a variable of type object, what will calling the method GetType on the variable return?
Answer: A Type object that represents the string class.
Lesson 5: Creating Code at Runtime
C14L5Q1: Which class is used to create a dynamic assembly?
Answer: AppDomain.
Lesson 1: Using Culture Information
C16L1Q1: What are the three culture categories?
Answer: Invariant, neutral and specific.
C16L1Q2: How can a string comparison be made that is specific to a culture and can use the CompareOptions class?
Answer:
- Create or get a reference to an CultureInfo object.
- Get a reference to the CompareInfo property of the CultureInfo object.
- Call the Compare method on the CompareInfo object and pass in the two strings to be compared and any CompareOtions required.
Pragmatic Programming
PragC2Q4: What is a technique for avoiding or reducing imposed duplication?
Answer: Code generation.
PragC2Q5: What is Meyer's Uniform Access principle?
Answer:
“All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation.”
or
“Class properties are good.”
PragC2Q6: What are two techniques for avoiding or reducing inadvertent duplication?
Answer: Normalise the data and don't store what can be calculated.
PragC2Q7: What should be done if the DRY principle needs to be violated for performance reasons?
Answer: Ensure the violation is not exposed to the outside world by keeping it contained with in the class.
PragC2Q8: How do you avoid impatient duplication?
Answer: Discipline.
PragC2Q9: What adage relates to impatient duplication?
Answer:
“Short cuts make for long delays.”
PragC2Q10: What is orthogonality?
Answer: Independence or decoupling.
PragC2Q11: What are the two major benefits of orthogonality?
Answer: Increased productivity and reduced risk.
PragC2Q12: How can you get an informal measurement of how orthogonal a team is?
Answer: Determine how many people need to be involved in discussing each change that is requested. The less people, the more orthogonal and better off the team is.
PragC2Q13: How can low orthogonality affect a team?
Answer: Confusion over responsibilities leading to bickering.
Article 1: Design Principles and Design Patterns, Robert C. Martin
Art1P2Q1: What are the four primary symptoms of rotting design?
Answer:
- Rigidity (changes cascade)
- Fragility (breaks whenever it is changed)
- Immobility (inability to reuse software from other projects or part of the system)
- Viscosity (easier for the engineers to break the design with hacks rather than preserve it)
Art1P4Q1: What kind of requirements changes cause design rot?
Answer: Changes that introduce new and unplanned for dependencies.
Art1P4Q2: What technique can be used to prevent degradation of the dependency architecture?
Answer: Dependency firewalls.
Art1P4Q3: What is the Open Closed Principle and who came up with it?
Answer:
“A module should be open for extension, but closed for modification.” - Bertrand Meyer
Art1P5Q1: What is the key to the OCP?
Answer: Abstraction.
Art1P8Q1: What is the Liskov Substitution Principle and who came up with it?
Answer:
“Subclasses should be substitutable for their base classes.” - Barbara Liskov
Art1P8Q2: What is the canonical example of the subtleties of the LSP?
Answer: The Circle / Ellipse dilemma.
Art1P12Q1: Violations of the LSP are also what?
Answer: Violations of the OCP.
Art1P12Q2: What is the Dependency Inversion Principle?
Answer:
“Depend on abstractions. Do not depend on concretions.”
Life Questions
LifeQ3: What is the effect / affect usage mnemonic?
Answer: VANE - Verb Affect Noun Effect
IT Questions
ITQ3: What is the Unicode number for the snowman character?
<html> <span style=“font-size:60px”>☃<span> </html>
Answer: 2603 (Hex).