Tuesday, November 29, 2016

Transitioning from C# to Java: Inheritance

Base classes are called superclasses and accordingly referenced with the keyword super rather than C# base. When declaring derived classes, Java extends (for superclasses) and implements (for interfaces) specify the same inheritance relationships for which C# uses simple colons (:).

C# virtual is missing entirely because all Java methods are virtual unless explicitly declared final

ADO.NET Example: Parameterized Query

string color = Request.Form["color"];
string SQLquery = "select * from Animals where color='" + @color + "'";
con = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["mycon"].ToString());
                con.Open();
                System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(SQLquery, con);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@color", color));

                System.Data.SqlClient.SqlDataReader rdr = null;
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    school.Url = (string)rdr["Url"];
                }
                return school;

Temp Tables

Remember, you don't have to create structure of temp table....


select deptName, deptId, count(*) as TotalEmp
into #TempEmpCount
from tblEmp join tblDept on tblEmp.DeptId = tblDept.DeptId
group by DeptName, DeptId


select DeptName, TotEmp
from #TempEmpCount
where TotalEmp >= 2

Drop Table #TempEmpCount

=====
Dropping is a "good practice"

Temp tables are stored in TempDB.
SCOPE: local only for current session, can be shared b/w nested sp calls.  Global are visible to other sessions and are destroyed when last connection referencing the table is closed.


=====

If you want to have a specific structure, use TABLE VARIABLE:

Declare @tblEmpCount table(DeptName nvarchar(20), DeptId int, TotalEmp int)

Insert @tblEmpCount
select DeptName, DeptId, Count(*) as TotalEmp from tblEmp......

Select DeptName, TotalEmp
from @tblEmpCount

====
NOTE: You don't have to drop table variables. And you can pass table variables as parameters between procedures.
===========

DERIVED TABLES:

select DeptName, TotEmp
from (
Select DeptName, DeptId, COUNT(*) as TotEmp
from tblEmp
join tblDept......
)  as EmpCount
where TotalEmp >= 2


==========
New in SQL SERVER 2005: CTE (Common Table Expressions)
Similar to derived table....

With EmpCount(DeptName, DeptId, TotEmp)
as (
Select DeptName, DeptId, COUNT(*) as TotEmp
from tblEmp
join tblDept...
)
Select DeptName, TotEmp
from EmpCount
where TotEmp >=2


Transitioning to Java from C#: static

Java lacks C# static classes. To create a class that only contains static utility methods, use the old-fashioned approach of defining a private default constructor. Java does have a static class modifier, but it means something completely different, and is for nested classes.

Transitioning to Java from C#

In C#, using String.Equals() and "==" are interchangeable (C# "special cases" the "=="), whereas in Java, there IS a big difference.

In Java, "==" is for pointer references, that is, it compares whether the actual INSTANCES are the same, whereas, to simply compare two VALUES, you have to use String.equals().


Monday, November 7, 2016

Agile cheatsheet

One way to accomplish Agile goals is via the use of Scrum.... the Scrum PROCESS or method.

Scrum process has:
2-4 week SPRINTS
DAILY STAND-UPS
product BACKLOG, User Stories.

RETROSPECTIVES.



Another way to accomplish Agile goals is via XP (Extreme Programming).


Good user stories have VERTICAL SLICES through the product.


Kanban (Japanese for billboard)(taskboard in XP)

yellow stickes showing status of each backlog item (Currently working on, Currently in QA, Done)

Burndown Chart: shows how the sprint is progressing, actual vs. plan.  Quantitative to Kanban's qualitative.

Pigs and Chickens.

Sprint Planning
Planning Poker (read user stories, give time estimates ....write down secretly, then share....)


XP:
Continuous integration
Coding standards,
Pair Programming,




HTML5 tables and borders

Since a few years ago, if you put in a table without ANY css, you are going to get a borderless table. Worse, if you put borders="1"  you will get the ugly, nasty  way old-school HTML double borders.  Worse STILL, even if you put the css for 1px solid black , you will STILL get the ugly double borders!!

The secret is to set the borders-collapse: to collapse.  (the default value is SEPARATE).




<style>
table {
    border-collapse: collapse;
}

table, td, th {
    border: 1px solid black;
}
</style>