« first day (1 day earlier)      last day (3179 days later) » 

00:29
@ckuhn203 what Visual Studio are you using?
(let's use this chatroom for that project)
00:55
@Mat'sMug Express 2012
I didn't set up a project. I just created the files from your post.
yeah, ...I'm forced to create a VBEX subfolder
ok it builds.
@ckuhn203 you know about SOLID?
SOLID?
No.
S = Single Responsibility Principle
O = Open/Closed Principle
L = Liskov Substution Principle
I = Interface Segregation Principle
D = Dependency Inversion Principle
In computer programming, SOLID (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) is a mnemonic acronym introduced by Michael Feathers for the "first five principles" named by Robert C. Martin in the early 2000s that stands for five basic principles of object-oriented programming and design. The principles, when applied together, intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time. The principles of SOLID are guidelines that can be applied while working on software to remov...
Seems like common sense, but not neccesarily something I'm extemely good at.
That's why there's Code Review!
:D
01:05
Truth. that's why I like it here.
I'm striving to write all my C# code by SOLID principles
I can see why.
that's why I chuckled at the comment on my post, ...cramming the ReadAllFiles, the logging, and file validation (and what else?) all in the same class, in the same method, is not what I think of code that's easy to maintain - with time it just grows features and new bugs emerge, things that used to work no longer work, ... if you keep classes and methods simple, you are making Mr.Maintainer a favor.. IMO.
Yes. I find myself thinking that way more and more.
Everything is a class. I don't want to think about it after I've written it once.
@ckuhn203 I had issues with Git integration in VS2012 Express, but it worked in VS2013 Express... mind upgrading to 2013?
01:11
Not a problem @Mat'sMug.
I can do it tomorrow. I've gotta get going soon.
pushed
I put the files in the VBEX.Parser namespace
ok
BTW, don't hesitate to ask about anything you don't know or aren't sure about - .net is quite a big framework to learn.
I will.
No doubt.
I have some reading to do. I don't quite get the interface thing.
Is it an abstract class?
rather an abstraction of a type.
an abstract class and an interface both represent abstractions, but interfaces cannot implement anything
an abstract class can be inherited; an interface can be implemented.
an abstract class may implement an interface
public interface ICodeFileReader
{
    string[] ReadFile(string path);
}
The type that implements this interface is guaranteed to have a ReadFile method taking a string parameter and returning a string[] array.
it's like some kind of a contract
if you have public class MyClass : ICodeFileReader and MyClass doesn't have a ReadFile method, the code won't compile.
changes to an interface are breaking changes, because all client code that inherits the modified interface then needs to be updated to implement the missing members - a type that implements an interface must implement all of the interface's members.
(am I going too fast?)
an abstract class is a class that cannot be instantiated directly - it must be inherited. An abstract class may define abstract members, and provide virtual implementations for other members.
The catch is that a type can only have a single base class, but can implement as many interfaces as needed.
Deriving from a base class (abstract or not) is an impactful design decision.
01:31
Nope. You're good.
cool!
That's what I thought. I just didn't know the terminology.
VS 2013 is installing.
So, you seem to have a game plan in your head. What do you need me to to do?
I think the Parser namespace is pretty much almost done with, all that's missing is that SourceCodeProvider class I mentioned earlier. How do you picture the Lexer namespace?
We're going to need a class for pretty much every language construct in VB6
The first thing that comes to mind is a CodeBlock abstract class
then a Procedure : CodeBlock class
CodeBlock is essentially something with a keyword at the beginning and another keyword at the end. It should have a Content property, I'm not sure of the type of that member though.
the idea is to give ourselves an API to model any code with objects
Probably a Declarations : CodeBlock class too. That's the two biggest chunks.
Nope. Nevermind. that falls outside the definition.
Wouldn't codeblock just be a string?
we need to make abstractions - I think a CodeModule could be contain a DeclarationsSection and a ContentSection, both derived from CodeSection and both with a Content property of ...some type.
the string representation should be covered with a public override string ToString()
basically we make enough objects to parse an entire VB code file into a bunch of objects, and then we can call .ToString() on these objects and re-generate the entire code file, or just the parts we're interested in, say, uh.. maybe you want to reorder procedures.
01:46
Right.
Drawing pictures.
One sec.
As a starting point.
looks about right
Actually the ContentSection should contain Members, yes, Member is the type I was looking for!
Members?
Explain before I recommend redefining CodeBlock.
lol
Property : Member, Method : Member, Field : Member (Field would be a member in the DeclarationsSection)
A Property has a CodeBlock, not is a ;)
02:00
Yes! Ok.
now there's a thing with properties..
A module contains nothing but members.
exactly
Go on.
private and public ones (and friend ones too)
02:01
Yup. Sounds right.
they may have a getter, a setter, and/or a "letter" (ugh.. we might not have a choice here)
Choice about what?
Letter : CodeBlock :(
The letter? It's part of the language. Ohhhh. Yeah.
"Letter", out-of-context is a confusing name I find
oh well, let's just blame VB
02:03
I mean, what else are we gonna call it, and we can't ignore it...
Blame VB
Ok, we have properties, subs, and functions. All of which can contain actual code blocks.
So however we differentiate there, they all need to implement very similar substructures.
yup
then if we want to analyze code, we'll need to model the method bodies too
that's where IfBlock : CodeBlock and friends come into play
we'll need an Identifier class
properties, subs, functions have an identifier also
wait, no
yes they do
they have an Identifier Name { get; } property
the identifier encapsulates the string
and then we can count unique identifiers in a code base!
and analyze naming conventions conformity!
Just so I get this straight in my head, what counts as an Identifier?
Just sub names & such, or do we include variables?
any constant, variable, procedure, ...everything that has a name and that VB considers as such
Rigth.
Ok. Just making sure we're on the same page.
wow this is going to be a pretty cool project!
02:12
Sidebar: I know how to use a regex to find un-dimmed variable names, so we're good there.
un-dimmed?
oh
nm / undeclared ;)
Regex needs perfected, but yes. I've done that analysis before.
Of course, that was an obfuscation project......
private, public and even global can be used in the declarations section to declare an identifier
I think we should resort to regex ...as a last resort ;)
You realize we're going half way to building an interpreter ourselves here. Are we getting in over our heads?
although it might not be crazy at all, in the code that instantiates all these objects from the string[]
I do
no sweat
you know how to eat an elephant?
02:16
One bite at a time.
one bite at a time! yes!
once a code file is modeled into a tree structure, there's not a lot of work required (lol. I must be way underestimating this) to effectively and correctly "translate" it into, say, VB.NET or even C#, and command-line build it into a COM-visible DLL that VBA can consume... picture doing that from the VBA IDE!
Escher would be proud.
lol
it all depends on the tree structure
the more accurately it describes the language/code, the better
if we make the correct abstractions, things should just ...flow.
I've never done this kind of coding BTW
that's why I want to do it :)
I've never tackled this kind of project. Everything is very "get it done". I hate that. So, I'm excited to tackle a real project.
I think we need some project plan, a backlog
02:26
We need a real UML doc.
Ever use Lucidchart?
ahhh crap. I can't share it.
Hmpf.
What about Freemind? We could keep the doc in the repo.
UML can be useful - good idea; I was thinking of something like Trello though, for tracking the todo's
I can learn to use it.
you can't delete a board though, I got pissed and deleted my account. but it's otherwise very well done :)
02:33
lol
I created an account a while back just to check it out.
me too, and then I subscribed to that board delete feature suggestion and then kept getting notifications for every comment on it for like 2 years. eventually I said, fuck it they're not going to implement it, and I'm tired of receiving these emails.
I'm adding a unit tests project to the solution, I'll commit later tonight
Ok. So, trello it is.
Sounds good. I'll be pretty busy tomorrow with wedding stuff.
I got 13 working and figured out how to connect to the git.
For reference, our current todos:
Set up board on Trello for Todos
Settle on a tool for object modeling
Finish sketching design
I've gotta get to bed before I'm no longer engaged. ttys
awesome!
later!
wait, your wedding?
congratulations!
lol. Yeah. It's in a few months. Thanks!
@Mat'sMug just figured it out. We'll have to export the module to a file then read it into memory with this to get at the attributes.
http://msdn.microsoft.com/en-us/library/aa443950(v=vs.60).aspx
02:54
so the CodeFileReader is probably the only ISourceCodeProvider we'll need to implement then
but we never know
that's what I like about proper abstractions
you can change your requirements at any point, and not break anything.
and unit tests are important too
I was writing a test for the FileHeaderValidatorCodeFileReader
and realized I could not test each validation rule independently
so I changed it
    public class FileHeaderValidatorCodeFileReader : CodeFileReaderDecorator
    {
        public static readonly int MinimumValidLineCount = 10;

        private readonly IEnumerable<ValidationRule> _validationRules;

        public FileHeaderValidatorCodeFileReader(ICodeFileReader reader, IEnumerable<ValidationRule> validationRules)
            : base(reader)
        {
            _validationRules = validationRules;
        }
and then the validation code is pretty simple:
            var isValid = false;
            foreach (var rule in _validationRules)
            {
                if (!rule.Evaluate(content))
                {
                    throw new InvalidFileHeaderException(rule);
                }
            }

            return content;
and now we can inject the validation rules at run time
and change them on a whim
        public class ValidationRule
        {
            private readonly string _name;
            private readonly string _message;
            private readonly Predicate<string[]> _validate;

            public ValidationRule(string name, string message, Predicate<string[]> rule)
            {
                _name = name;
                _message = message;
                _validate = rule;
            }

            public string Name { get { return _name; } }
            public string Message { get { return _message; } }
^^ this is where you say huh? what's a Predicate<string[]>?
or you know LINQ already?
side note, I like VS2013 much better than VS2012 (first time using it)
the exception:
        public class InvalidFileHeaderException : FormatException
        {
            private readonly ValidationRule _rule;

            public InvalidFileHeaderException(ValidationRule rule)
                :base(rule.Message)
            {
                _rule = rule;
            }

            public ValidationRule Rule { get { return _rule; } }
        }
not sure deriving from FormatException is a good call though.
but that's already up for review, I wonder if anyone will point it out
 
8 hours later…
11:12
The file reader may not be the only thing we need. I'd ill to be able to *write back* to the module too; not just analyze code, but update it. Insert snippets.

You were right. I had to look up what a predicate is. Still haven't completely wrapped my head around it. I will though.
11:31
I am going to remind you that I'm still just scratching the surface of c#.
I'll need to step through the code before I really understand it.

« first day (1 day earlier)      last day (3179 days later) »