Thursday, April 30, 2020

What to work on in my own choice - coding and design?

April 30, 2020

Introduction


It is serious lesson for me to learn as an investor. I did not know to sell high and buy low, since VAB.TO went up last month with gains $2000 dollars, and then in less than 12 business days, it went down with loss $1500 dollars. I did not learn the importance to sell high and buy low. From the lesson, I learn that I have to go back to simplify things at work, so that I can have more time to learn how to invest after the work. Technology eats my time, I have to think about Coronavirus, emergency, how I should support business without too much burden on myself as a software programmer. I am the only developer and then we like to continue to run business since we all have to live and do not like to get into debt.


My showcase project at work


I like to write down a short showcase how I made some modification in my code base.

Here is the link of C# code.
Here is the link of CSS code.
Here is the link of C# code for a small class.


I need to find time to review CSS, and this time I reviewed CSS style from Uber. Here is the link.

C# code more readable:


/// <summary>
/// code review on April 24, 2020
/// add id in html for each div element to make code readable
///
/// Code review on July 7, 2017
/// March 14, 2016
/// Cannot be extracted, because Server.MapPath(pngFile) <- check IIS server file exists or not
/// January 4, 2016
/// Add "ABS" to the list
/// </summary>
/// <param name="mainMenu"></param>
/// <param name="subMenu"></param>
/// <param name="name"></param>
/// <param name="imagePath"></param>
/// <param name="text"></param>
/// <param name="products"></param>
/// <returns></returns>
public static string prepareHtml(
string mainMenu,
string subMenu,
string name,
string imagePath,
string text,
IEnumerable<PictureSlideColumns> products)
{
string urlKey = getUrlStr(mainMenu, subMenu);
string imgUrlHelper = Image_render.getHelperString(name, urlKey, imagePath);
string cssClass = CssClassTitle.GetName(text);
string html = "";
for (int i = 0; i < products.Count(); i++)
{
var visit = products.ElementAt(i);
var mountName = visit.MountName;
var mountWebName = visit.MountOnWeb;
var subTitle = visit.SubTitle;
var fileName = imgUrlHelper + mountName;
// HOLD: if .png img file exists, then .png will be displayed; otherwise, go for .img file
string imageFile = fileName + ".jpg";
var index = i.ToString();
var prefixs = new string[] {"titleDiv" + index,"subTitleDiv" + index,"imgDiv" + index};
var list = new List<string>();
list.Add(composeOuterDiv(cssClass, prefixs[0], mountWebName));
list.Add(MainSlideShow.Html.HtmlDivSubTitle.Compose(prefixs[1], subTitle));
list.Add(getImageHtml(prefixs[2], imageFile));
// a div for each product
var htmlDiv = "";
var finishClass = getFinishClass(name, mountName);
htmlDiv += "<div class=\"slide " + finishClass + "\">";
htmlDiv += String.Join("", list.ToArray());
htmlDiv += "</div>";
html += htmlDiv;
}
return html;
}
/// <summary>
/// April 27, 2020
/// add div id for each div
/// </summary>
/// <param name="cssClass"></param>
/// <param name="divName"></param>
/// <param name="mountWebName"></param>
/// <returns></returns>
private static string composeOuterDiv(string cssClass, string divName, string mountWebName)
{
return "<div id=\"" + divName + "\" class=\"mount_id " + cssClass + "\" class=\"grid_2\">" + mountWebName + "</div>";
}



Html code more readable with div names:


No comments:

Post a Comment