Skip to content

Commit 5872a56

Browse files
committed
Removed comments after watching a great lecture by Kevlin Henney - Seven Ineffective Coding Habits of Many Programmers
https://www.youtube.com/watch?v=ZsHMHukIlJY
1 parent 6c5176a commit 5872a56

File tree

4 files changed

+5
-334
lines changed

4 files changed

+5
-334
lines changed

CS/Scripts/AssemblyInfo.cs

-91
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,10 @@
66
using System.Deployment.Application;
77
using Microsoft.Win32;
88

9-
// <summary>
10-
// This namespaces if for generic application classes
11-
// </summary>
129
namespace Markup.Scripts
1310
{
14-
/// <summary>
15-
/// Used to get the assembly information
16-
/// </summary>
17-
/// <remarks>
18-
/// http://danielsaidi.wordpress.com/2009/05/25/c-get-assembly-information/
19-
/// </remarks>
2011
public static class AssemblyInfo
2112
{
22-
/// <summary>
23-
/// Title
24-
/// </summary>
25-
/// <remarks>
26-
/// </remarks>
2713
public static string Title
2814
{
2915
get
@@ -42,11 +28,6 @@ public static string Title
4228
}
4329
}
4430

45-
/// <summary>
46-
/// Description
47-
/// </summary>
48-
/// <remarks>
49-
/// </remarks>
5031
public static string Description
5132
{
5233
get
@@ -64,11 +45,6 @@ public static string Description
6445
}
6546
}
6647

67-
/// <summary>
68-
/// Company
69-
/// </summary>
70-
/// <remarks>
71-
/// </remarks>
7248
public static string Company
7349
{
7450
get
@@ -87,11 +63,6 @@ public static string Company
8763
}
8864
}
8965

90-
/// <summary>
91-
/// Product
92-
/// </summary>
93-
/// <remarks>
94-
/// </remarks>
9566
public static string Product
9667
{
9768
get
@@ -109,11 +80,6 @@ public static string Product
10980
}
11081
}
11182

112-
/// <summary>
113-
/// Copyright
114-
/// </summary>
115-
/// <remarks>
116-
/// </remarks>
11783
public static string Copyright
11884
{
11985
get
@@ -131,11 +97,6 @@ public static string Copyright
13197
}
13298
}
13399

134-
/// <summary>
135-
/// Trademark
136-
/// </summary>
137-
/// <remarks>
138-
/// </remarks>
139100
public static string Trademark
140101
{
141102
get
@@ -153,11 +114,6 @@ public static string Trademark
153114
}
154115
}
155116

156-
/// <summary>
157-
/// AssemblyVersion
158-
/// </summary>
159-
/// <remarks>
160-
/// </remarks>
161117
public static string AssemblyVersion
162118
{
163119
get
@@ -167,11 +123,6 @@ public static string AssemblyVersion
167123
}
168124
}
169125

170-
/// <summary>
171-
/// FileVersion
172-
/// </summary>
173-
/// <remarks>
174-
/// </remarks>
175126
public static string FileVersion
176127
{
177128
get
@@ -182,11 +133,6 @@ public static string FileVersion
182133
}
183134
}
184135

185-
/// <summary>
186-
/// Guid
187-
/// </summary>
188-
/// <remarks>
189-
/// </remarks>
190136
public static string Guid
191137
{
192138
get
@@ -204,11 +150,6 @@ public static string Guid
204150
}
205151
}
206152

207-
/// <summary>
208-
/// FileName
209-
/// </summary>
210-
/// <remarks>
211-
/// </remarks>
212153
public static string FileName
213154
{
214155
get
@@ -219,11 +160,6 @@ public static string FileName
219160
}
220161
}
221162

222-
/// <summary>
223-
/// FilePath
224-
/// </summary>
225-
/// <remarks>
226-
/// </remarks>
227163
public static string FilePath
228164
{
229165
get
@@ -234,11 +170,6 @@ public static string FilePath
234170
}
235171
}
236172

237-
/// <summary>
238-
/// Return the current file name (used for error logging)
239-
/// </summary>
240-
/// <returns>A method that returns a string of the current file name </returns>
241-
/// <remarks></remarks>
242173
public static string GetCurrentFileName()
243174
{
244175
try
@@ -251,11 +182,6 @@ public static string GetCurrentFileName()
251182
}
252183
}
253184

254-
/// <summary>
255-
/// Returns the ClickOnce location
256-
/// </summary>
257-
/// <returns>A method that returns a string of the current location </returns>
258-
/// <remarks></remarks>
259185
public static string GetClickOnceLocation()
260186
{
261187
try
@@ -273,11 +199,6 @@ public static string GetClickOnceLocation()
273199

274200
}
275201

276-
/// <summary>
277-
/// Returns the assembly location
278-
/// </summary>
279-
/// <returns>A method that returns a string of the current location </returns>
280-
/// <remarks></remarks>
281202
public static string GetAssemblyLocation()
282203
{
283204
try
@@ -294,13 +215,6 @@ public static string GetAssemblyLocation()
294215

295216
}
296217

297-
/// <summary>
298-
/// set the icon in add/remove programs
299-
/// </summary>
300-
/// <param name="iconName">The referenced icon name for the application.</param>
301-
/// <remarks>
302-
/// only run if deployed
303-
/// </remarks>
304218
public static void SetAddRemoveProgramsIcon(string iconName)
305219
{
306220
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed
@@ -339,11 +253,6 @@ public static void SetAddRemoveProgramsIcon(string iconName)
339253
}
340254
}
341255

342-
/// <summary>
343-
/// Open a file as read only
344-
/// </summary>
345-
/// <param name="filePath">Represents the file path string </param>
346-
/// <remarks></remarks>
347256
public static void OpenFile(string filePath)
348257
{
349258
try

CS/Scripts/ErrorHandler.cs

+1-53
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@
1010

1111
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
1212

13-
// <summary>
14-
// This namespaces if for generic application classes
15-
// </summary>
1613
namespace Markup.Scripts
1714
{
18-
/// <summary>
19-
/// Used to handle exceptions
20-
/// </summary>
2115
public class ErrorHandler
2216
{
2317
private static readonly ILog log = LogManager.GetLogger(typeof(ErrorHandler));
2418

25-
/// <summary>
26-
/// Applies a new path for the log file by FileAppender name
27-
/// </summary>
2819
public static void SetLogPath()
2920
{
3021
XmlConfigurator.Configure();
@@ -44,9 +35,6 @@ public static void SetLogPath()
4435
}
4536
}
4637

47-
/// <summary>
48-
/// Create a log record to track which methods are being used.
49-
/// </summary>
5038
public static void CreateLogRecord()
5139
{
5240
try
@@ -73,27 +61,14 @@ public static void CreateLogRecord()
7361
}
7462
}
7563

76-
/// <summary>
77-
/// Used to produce an error message and create a log record
78-
/// <example>
79-
/// <code lang="C#">
80-
/// ErrorHandler.DisplayMessage(ex);
81-
/// </code>
82-
/// </example>
83-
/// </summary>
84-
/// <param name="ex">Represents errors that occur during application execution.</param>
85-
/// <param name="isSilent">Used to show a message to the user and log an error record or just log a record.</param>
86-
/// <remarks></remarks>
8764
public static void DisplayMessage(Exception ex, Boolean isSilent = false)
8865
{
89-
// gather context
9066
var sf = new System.Diagnostics.StackFrame(1);
9167
var caller = sf.GetMethod();
92-
var errorDescription = ex.ToString().Replace("\r\n", " "); // the carriage returns were messing up my log file
68+
var errorDescription = ex.ToString().Replace("\r\n", " ");
9369
var currentProcedure = caller.Name.Trim();
9470
var currentFileName = AssemblyInfo.GetCurrentFileName();
9571

96-
// handle log record
9772
var logMessage = string.Concat(new Dictionary<string, string>
9873
{
9974
["PROCEDURE"] = currentProcedure,
@@ -104,26 +79,18 @@ public static void DisplayMessage(Exception ex, Boolean isSilent = false)
10479
}.Select(x => $"[{x.Key}]=|{x.Value}|"));
10580
log.Error(logMessage);
10681

107-
// format message
10882
var userMessage = new StringBuilder()
10983
.AppendLine("Contact your system administrator. A record has been created in the log file.")
11084
.AppendLine("Procedure: " + currentProcedure)
11185
.AppendLine("Description: " + errorDescription)
11286
.ToString();
11387

114-
// handle message
11588
if (isSilent == false)
11689
{
11790
MessageBox.Show(userMessage, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
11891
}
11992
}
12093

121-
/// <summary>
122-
/// Check to see if there is an active document
123-
/// </summary>
124-
/// <param name="showMsg">To show a message </param>
125-
/// <returns>A method that returns true or false if there is an active document </returns>
126-
/// <remarks></remarks>
12794
public static bool IsActiveDocument(bool showMsg = false)
12895
{
12996
try
@@ -148,12 +115,6 @@ public static bool IsActiveDocument(bool showMsg = false)
148115
}
149116
}
150117

151-
/// <summary>
152-
/// Check to see if there is an active selection
153-
/// </summary>
154-
/// <param name="showMsg">To show a message </param>
155-
/// <returns>A method that returns true or false if there is an active selection </returns>
156-
/// <remarks></remarks>
157118
public static bool IsActiveSelection(bool showMsg = false)
158119
{
159120
Excel.Range checkRange = null;
@@ -185,13 +146,6 @@ public static bool IsActiveSelection(bool showMsg = false)
185146
}
186147
}
187148

188-
/// <summary>
189-
/// This method check whether Excel is in Cell Editing mode or not
190-
/// There are few ways to check this (eg. check to see if a standard menu item is disabled etc.)
191-
/// I know in cell editing mode app.DisplayAlerts throws an Exception, so here I'm relying on that behaviour
192-
/// </summary>
193-
/// <param name="showMsg">To show a message </param>
194-
/// <returns>true if Excel is in cell editing mode</returns>
195149
private static bool IsInCellEditingMode(bool showMsg = false)
196150
{
197151
bool flag = false;
@@ -210,12 +164,6 @@ private static bool IsInCellEditingMode(bool showMsg = false)
210164
return flag;
211165
}
212166

213-
/// <summary>
214-
/// Can an object be inserted
215-
/// </summary>
216-
/// <param name="showMsg">To show a message </param>
217-
/// <returns>A method that returns true or false if an object can be enabled </returns>
218-
/// <remarks></remarks>
219167
public static bool IsEnabled(bool showMsg = false)
220168
{
221169
try

0 commit comments

Comments
 (0)